XSLT schema

The generated XSLT stylesheet used as a schema is deliberately more verbose. It generates a single line of text output for each occurrence of selector in the input which indicates whether or not the value of said selector matches the generated regular expression or not. Figure 2, “XSLT schema, validation” shows a pared-down version of the generated XSLT stylesheet. Again, GENERATED_REGEXP_HERE indicates where in the output the generation routine places the regular expression.

Figure 2. XSLT schema, validation

<?xml version="1.0" encoding="UTF-8"?>

  <xsl:variable name="selector_regex">
  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:apply-templates select="//*[@selector]"/>
  <xsl:template match="*">
    <xsl:value-of select="'selector “'
                          ||'” is&#x09;&#x09;'"/>
      test="not( matches( @selector, $anchored_selector_regex ) )">NOT </xsl:if>
    <xsl:value-of select="'valid.&#x0A;'"/>