<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!--
  checker.xsd

  This XSD describes the checker format used by the validator to
  internally represent its state machine. The validator will ensure
  that all checker documents conform to this schema before they are
  processed.
-->
<schema
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:chk="http://www.rackspace.com/repose/wadl/checker"
    xmlns:saxon="http://saxon.sf.net/"
    xmlns:xerces="http://xerces.apache.org"
    targetNamespace="http://www.rackspace.com/repose/wadl/checker">

    <import namespace="http://www.w3.org/1999/XSL/Transform"
            schemaLocation="transform.xsd"/>

    <!-- The Checker Element -->
    <element name="checker" type="chk:Checker"/>

    <!-- Complex Types -->
    <complexType name="Step">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                   Base type for all other steps.
                </html:p>
            </documentation>
        </annotation>
        <attribute name="id" type="xsd:ID" use="required"/>
        <attribute name="type" type="chk:StepType" use="required"/>
        <attribute name="label" type="xsd:string" use="optional"/>
    </complexType>

    <complexType name="Checker">
        <sequence>
            <element name="grammar" type="chk:Grammar" minOccurs="0" maxOccurs="unbounded"/>
            <element name="step" type="chk:Step" minOccurs="0" maxOccurs="unbounded">
                <alternative test="@type eq 'START'" type="chk:StartStep"/>
                <alternative test="@type eq 'URL_FAIL'" type="chk:URLFailStep"/>
                <alternative test="@type eq 'METHOD_FAIL'" type="chk:MethodFailStep"/>
                <alternative test="@type eq 'CONTENT_FAIL'" type="chk:ContentFailStep"/>
                <alternative test="@type eq 'ACCEPT'" type="chk:AcceptStep"/>
                <alternative test="@type eq 'URL'" type="chk:URLStep"/>
                <alternative test="@type eq 'METHOD'" type="chk:MethodStep"/>
                <alternative test="@type eq 'URLXSD'" type="chk:URLXSDStep"/>
                <alternative test="@type eq 'REQ_TYPE'" type="chk:ReqTypeStep"/>
                <alternative test="@type eq 'REQ_TYPE_FAIL'" type="chk:ReqTypeFailStep"/>
                <alternative test="@type eq 'WELL_XML'" type="chk:WellFormedXMLStep"/>
                <alternative test="@type eq 'WELL_JSON'" type="chk:WellFormedJSONStep"/>
                <alternative test="@type eq 'XSD'" type="chk:XSDStep"/>
                <alternative test="@type eq 'XPATH'" type="chk:XPathStep"/>
                <alternative test="@type eq 'XSL'" type="chk:XSLStep"/>
                <alternative test="@type eq 'HEADER'" type="chk:HeaderStep"/>
                <alternative test="@type eq 'HEADERXSD'" type="chk:HeaderXSDStep"/>
                <alternative test="@type eq 'HEADER_ANY'" type="chk:HeaderAnyStep"/>
                <alternative test="@type eq 'HEADERXSD_ANY'" type="chk:HeaderXSDAnyStep"/>
            </element>
        </sequence>
        <assert test="if (count(chk:step[@type='START']) = 1) then true() else false()"
                saxon:message="There should be 1 and only 1 step of type START.">
            <annotation>
                <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                    <html:p>
                        There should be a single START node.
                    </html:p>
                </documentation>
            </annotation>
        </assert>
        <assert test="count(chk:step[@id = tokenize(string-join(..//chk:step/@next,' '),' ')]) = count(chk:step[@type != 'START'])"
                saxon:message="Every step must be connected">
            <annotation>
                <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                    <html:p>
                        Every step must be connected.
                    </html:p>
                </documentation>
            </annotation>
        </assert>
    </complexType>

    <!-- Connected Steps -->
    <complexType name="ConnectedStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A base step type for all steps that connect to other steps.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="next" type="xsd:IDREFS" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="StartStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A start step, denotes the start of the machine.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep"/>
        </complexContent>
    </complexType>

    <complexType name="WellFormedXMLStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the content contains well formed XML.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep"/>
        </complexContent>
    </complexType>

    <complexType name="WellFormedJSONStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the content contains well formed JSON.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep"/>
        </complexContent>
    </complexType>

    <complexType name="XSDStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the XML content validates against the
                    XSDs provided in the grammar.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="transform" type="xsd:boolean" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                If transform is 'true' then the
                                validation step will transform the
                                input, to fill in default values.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="XSLStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Transforms the content via some XSL.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <sequence>
                    <choice minOccurs="0">
                        <element ref="xsl:transform"/>
                        <element ref="xsl:stylesheet"/>
                    </choice>
                </sequence>
                <attribute name="href" type="xsd:anyURI" use="optional"/>
                <attribute name="version" type="chk:XSLVersion" use="required"/>
                <assert test="if (@href and (xsl:stylesheet or xsl:transform)) then false() else true() "
                        saxon:message="Can't define an inline transform and also include a href"/>
                <assert test="if (not(@href)) then (xsl:stylesheet or xsl:transform) else true()"
                        saxon:message="An XSL step must contain an href or an inline transformation"
                        xerces:message="An XSL step must contain an href or an inline transformation"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="XPathStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the XPATH evaluates to true() in the
                    XML content. The match is an XPath expression.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
                <attribute name="version" type="chk:XPathVersion" use="optional"/>
                <attribute name="message" type="xsd:string" use="optional"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="URLStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step in the URL path. The match attribute
                    contains a regex that matches the steps section of
                    the path.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="URLXSDStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step in the URL path. The match attribute
                    contains a QName that is used to represent an XSD
                    simple type that validates against the section of
                    the path.
                </html:p>
                <html:p>
                    Note: If possible, should extend to make sure tha
                    the simple type is defined by a referenced schema.
                    We're not there yet.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:QName" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="HeaderStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A check on a required header. The match attribute
                    contains a regex that matches the header value.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="name" type="xsd:string" use="required"/>
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="HeaderAnyStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Exactly like HeaderStep, except that given
                    multiple headers, this step accepts if *any* of
                    the header values pass.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:HeaderStep"/>
        </complexContent>
    </complexType>

    <complexType name="HeaderXSDStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A check on a required header. The match attribute
                    contains a QName that is used to represent an XSD
                    simple type that validates the header value.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="name" type="xsd:string" use="required"/>
                <attribute name="match" type="xsd:QName" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="HeaderXSDAnyStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Exactly like HeaderXSDStep, except that given
                    multiple headers, this step accepts if *any* of
                    the header values pass.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:HeaderXSDStep"/>
        </complexContent>
    </complexType>

    <complexType name="MethodStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step checking the current method.  The match
                    attribute contains a regex that matches against
                    the method name.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ReqTypeStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step checking the request content type.  The
                    match attribute contains a regex that matches
                    against the content type mimetype.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <!-- End Steps -->
    <complexType name="AcceptStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    An accept step, we accept the input.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step"/>
        </complexContent>
    </complexType>

    <complexType name="URLFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A URLFail step, this should generate a 404 (Not
                    Found). If the notMatch and notTypes attributes
                    are missing the step always applies.  If the
                    attributes are present, the present attributes
                    must be satisfied in order of the step to apply.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="notMatch" type="xsd:string" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A URLFail step applies only if the
                                current URL segment does
                                <html:strong>not</html:strong>
                                validate against the regex listed in
                                this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
                <attribute name="notTypes" type="chk:QNameList" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A URLFail step applies if the
                                current URL segment does
                                <html:strong>not</html:strong>
                                validate against any in the list of
                                simple types listed in this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="MethodFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A MethodFail step, this should generate a 405
                    (Method Not Allowed). If the notMatch attribute is
                    missing the step always applies.  If the attribute
                    is present, it must be satisfied in order of the
                    step to apply.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="notMatch" type="xsd:string" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A MethodFail step applies if the
                                current method does
                                <html:strong>not</html:strong>
                                validate against the regex listed in
                                this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ReqTypeFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A MethodFail step, this should generate a 415
                    (Unsupported Media Type). The notMatch attribute
                    must be satisfied in order for the step to apply.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="notMatch" type="xsd:string" use="required">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A ReqTypeFailStep applies if the
                                current request content type does
                                <html:strong>not</html:strong>
                                validate against the regex listed in
                                this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ContentFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A ContentFail step, this should generate a 400
                    (BadContent).
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step"/>
        </complexContent>
    </complexType>

    <!-- Grammar Def -->
    <complexType name="Grammar">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Describes a grammar needed for validation by the
                    checker.
                </html:p>
            </documentation>
        </annotation>
        <sequence>
            <!--
                 Pretty lax check for now, not really any schema type
                 we use the assertion to restrict this to
                 xsd:schema only.

                 TODO, bring in XSD 1.1 schema and actually validate.
            -->
            <any minOccurs="0" maxOccurs="1" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax"/>
        </sequence>
        <attribute name="type" type="chk:GrammarType" use="optional" default="W3C_XML"/>
        <attribute name="ns" type="xsd:string" use="optional"/>
        <attribute name="href" type="xsd:anyURI" use="optional"/>
        <assert test="if (xsd:*) then xsd:schema else true()"
                saxon:message="Only xsd:schema element is allowed!"/>
        <assert test="if (xsd:schema and @href) then false() else true()"
                saxon:message="Grammar can't have both an href and a schema"/>
    </complexType>

    <!-- Simple Types -->
    <simpleType name="StepType">
        <restriction base="xsd:string">
            <enumeration value="START"/>
            <enumeration value="URL_FAIL"/>
            <enumeration value="METHOD_FAIL"/>
            <enumeration value="ACCEPT"/>
            <enumeration value="URL"/>
            <enumeration value="METHOD"/>
            <enumeration value="URLXSD"/>
            <enumeration value="REQ_TYPE"/>
            <enumeration value="REQ_TYPE_FAIL"/>
            <enumeration value="WELL_XML"/>
            <enumeration value="WELL_JSON"/>
            <enumeration value="CONTENT_FAIL"/>
            <enumeration value="XSD"/>
            <enumeration value="XPATH"/>
            <enumeration value="XSL"/>
            <enumeration value="HEADER"/>
            <enumeration value="HEADERXSD"/>
            <enumeration value="HEADER_ANY"/>
            <enumeration value="HEADERXSD_ANY"/>
        </restriction><commit_msg>Added xerces messages to builder schema.<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!--
  checker.xsd

  This XSD describes the checker format used by the validator to
  internally represent its state machine. The validator will ensure
  that all checker documents conform to this schema before they are
  processed.
-->
<schema
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:chk="http://www.rackspace.com/repose/wadl/checker"
    xmlns:saxon="http://saxon.sf.net/"
    xmlns:xerces="http://xerces.apache.org"
    targetNamespace="http://www.rackspace.com/repose/wadl/checker">

    <import namespace="http://www.w3.org/1999/XSL/Transform"
            schemaLocation="transform.xsd"/>

    <!-- The Checker Element -->
    <element name="checker" type="chk:Checker"/>

    <!-- Complex Types -->
    <complexType name="Step">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                   Base type for all other steps.
                </html:p>
            </documentation>
        </annotation>
        <attribute name="id" type="xsd:ID" use="required"/>
        <attribute name="type" type="chk:StepType" use="required"/>
        <attribute name="label" type="xsd:string" use="optional"/>
    </complexType>

    <complexType name="Checker">
        <sequence>
            <element name="grammar" type="chk:Grammar" minOccurs="0" maxOccurs="unbounded"/>
            <element name="step" type="chk:Step" minOccurs="0" maxOccurs="unbounded">
                <alternative test="@type eq 'START'" type="chk:StartStep"/>
                <alternative test="@type eq 'URL_FAIL'" type="chk:URLFailStep"/>
                <alternative test="@type eq 'METHOD_FAIL'" type="chk:MethodFailStep"/>
                <alternative test="@type eq 'CONTENT_FAIL'" type="chk:ContentFailStep"/>
                <alternative test="@type eq 'ACCEPT'" type="chk:AcceptStep"/>
                <alternative test="@type eq 'URL'" type="chk:URLStep"/>
                <alternative test="@type eq 'METHOD'" type="chk:MethodStep"/>
                <alternative test="@type eq 'URLXSD'" type="chk:URLXSDStep"/>
                <alternative test="@type eq 'REQ_TYPE'" type="chk:ReqTypeStep"/>
                <alternative test="@type eq 'REQ_TYPE_FAIL'" type="chk:ReqTypeFailStep"/>
                <alternative test="@type eq 'WELL_XML'" type="chk:WellFormedXMLStep"/>
                <alternative test="@type eq 'WELL_JSON'" type="chk:WellFormedJSONStep"/>
                <alternative test="@type eq 'XSD'" type="chk:XSDStep"/>
                <alternative test="@type eq 'XPATH'" type="chk:XPathStep"/>
                <alternative test="@type eq 'XSL'" type="chk:XSLStep"/>
                <alternative test="@type eq 'HEADER'" type="chk:HeaderStep"/>
                <alternative test="@type eq 'HEADERXSD'" type="chk:HeaderXSDStep"/>
                <alternative test="@type eq 'HEADER_ANY'" type="chk:HeaderAnyStep"/>
                <alternative test="@type eq 'HEADERXSD_ANY'" type="chk:HeaderXSDAnyStep"/>
            </element>
        </sequence>
        <assert test="if (count(chk:step[@type='START']) = 1) then true() else false()"
                saxon:message="There should be 1 and only 1 step of type START."
                xerces:message="There should be 1 and only 1 step of type START.">
            <annotation>
                <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                    <html:p>
                        There should be a single START node.
                    </html:p>
                </documentation>
            </annotation>
        </assert>
        <assert test="count(chk:step[@id = tokenize(string-join(..//chk:step/@next,' '),' ')]) = count(chk:step[@type != 'START'])"
                saxon:message="Every step must be connected"
                xerces:message="Every step must be connected">
            <annotation>
                <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                    <html:p>
                        Every step must be connected.
                    </html:p>
                </documentation>
            </annotation>
        </assert>
    </complexType>

    <!-- Connected Steps -->
    <complexType name="ConnectedStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A base step type for all steps that connect to other steps.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="next" type="xsd:IDREFS" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="StartStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A start step, denotes the start of the machine.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep"/>
        </complexContent>
    </complexType>

    <complexType name="WellFormedXMLStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the content contains well formed XML.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep"/>
        </complexContent>
    </complexType>

    <complexType name="WellFormedJSONStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the content contains well formed JSON.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep"/>
        </complexContent>
    </complexType>

    <complexType name="XSDStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the XML content validates against the
                    XSDs provided in the grammar.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="transform" type="xsd:boolean" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                If transform is 'true' then the
                                validation step will transform the
                                input, to fill in default values.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="XSLStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Transforms the content via some XSL.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <sequence>
                    <choice minOccurs="0">
                        <element ref="xsl:transform"/>
                        <element ref="xsl:stylesheet"/>
                    </choice>
                </sequence>
                <attribute name="href" type="xsd:anyURI" use="optional"/>
                <attribute name="version" type="chk:XSLVersion" use="required"/>
                <assert test="if (@href and (xsl:stylesheet or xsl:transform)) then false() else true() "
                        saxon:message="Can't define an inline transform and also include a href"
                        xerces:message="Can't define an inline transform and also include a href"/>
                <assert test="if (not(@href)) then (xsl:stylesheet or xsl:transform) else true()"
                        saxon:message="An XSL step must contain an href or an inline transformation"
                        xerces:message="An XSL step must contain an href or an inline transformation"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="XPathStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Ensures that the XPATH evaluates to true() in the
                    XML content. The match is an XPath expression.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
                <attribute name="version" type="chk:XPathVersion" use="optional"/>
                <attribute name="message" type="xsd:string" use="optional"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="URLStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step in the URL path. The match attribute
                    contains a regex that matches the steps section of
                    the path.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="URLXSDStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step in the URL path. The match attribute
                    contains a QName that is used to represent an XSD
                    simple type that validates against the section of
                    the path.
                </html:p>
                <html:p>
                    Note: If possible, should extend to make sure tha
                    the simple type is defined by a referenced schema.
                    We're not there yet.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:QName" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="HeaderStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A check on a required header. The match attribute
                    contains a regex that matches the header value.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="name" type="xsd:string" use="required"/>
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="HeaderAnyStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Exactly like HeaderStep, except that given
                    multiple headers, this step accepts if *any* of
                    the header values pass.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:HeaderStep"/>
        </complexContent>
    </complexType>

    <complexType name="HeaderXSDStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A check on a required header. The match attribute
                    contains a QName that is used to represent an XSD
                    simple type that validates the header value.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="name" type="xsd:string" use="required"/>
                <attribute name="match" type="xsd:QName" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="HeaderXSDAnyStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Exactly like HeaderXSDStep, except that given
                    multiple headers, this step accepts if *any* of
                    the header values pass.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:HeaderXSDStep"/>
        </complexContent>
    </complexType>

    <complexType name="MethodStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step checking the current method.  The match
                    attribute contains a regex that matches against
                    the method name.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ReqTypeStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A step checking the request content type.  The
                    match attribute contains a regex that matches
                    against the content type mimetype.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:ConnectedStep">
                <attribute name="match" type="xsd:string" use="required"/>
            </extension>
        </complexContent>
    </complexType>

    <!-- End Steps -->
    <complexType name="AcceptStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    An accept step, we accept the input.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step"/>
        </complexContent>
    </complexType>

    <complexType name="URLFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A URLFail step, this should generate a 404 (Not
                    Found). If the notMatch and notTypes attributes
                    are missing the step always applies.  If the
                    attributes are present, the present attributes
                    must be satisfied in order of the step to apply.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="notMatch" type="xsd:string" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A URLFail step applies only if the
                                current URL segment does
                                <html:strong>not</html:strong>
                                validate against the regex listed in
                                this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
                <attribute name="notTypes" type="chk:QNameList" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A URLFail step applies if the
                                current URL segment does
                                <html:strong>not</html:strong>
                                validate against any in the list of
                                simple types listed in this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="MethodFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A MethodFail step, this should generate a 405
                    (Method Not Allowed). If the notMatch attribute is
                    missing the step always applies.  If the attribute
                    is present, it must be satisfied in order of the
                    step to apply.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="notMatch" type="xsd:string" use="optional">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A MethodFail step applies if the
                                current method does
                                <html:strong>not</html:strong>
                                validate against the regex listed in
                                this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ReqTypeFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A MethodFail step, this should generate a 415
                    (Unsupported Media Type). The notMatch attribute
                    must be satisfied in order for the step to apply.
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step">
                <attribute name="notMatch" type="xsd:string" use="required">
                    <annotation>
                        <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                            <html:p>
                                A ReqTypeFailStep applies if the
                                current request content type does
                                <html:strong>not</html:strong>
                                validate against the regex listed in
                                this attribute.
                            </html:p>
                        </documentation>
                    </annotation>
                </attribute>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ContentFailStep">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    A ContentFail step, this should generate a 400
                    (BadContent).
                </html:p>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="chk:Step"/>
        </complexContent>
    </complexType>

    <!-- Grammar Def -->
    <complexType name="Grammar">
        <annotation>
            <documentation xmlns:html="http://www.w3.org/1999/xhtml">
                <html:p>
                    Describes a grammar needed for validation by the
                    checker.
                </html:p>
            </documentation>
        </annotation>
        <sequence>
            <!--
                 Pretty lax check for now, not really any schema type
                 we use the assertion to restrict this to
                 xsd:schema only.

                 TODO, bring in XSD 1.1 schema and actually validate.
            -->
            <any minOccurs="0" maxOccurs="1" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax"/>
        </sequence>
        <attribute name="type" type="chk:GrammarType" use="optional" default="W3C_XML"/>
        <attribute name="ns" type="xsd:string" use="optional"/>
        <attribute name="href" type="xsd:anyURI" use="optional"/>
        <assert test="if (xsd:*) then xsd:schema else true()"
                saxon:message="Only xsd:schema element is allowed!"
                xerces:message="Only xsd:schema element is allowed!"/>
        <assert test="if (xsd:schema and @href) then false() else true()"
                saxon:message="Grammar can't have both an href and a schema"
                xerces:message="Grammar can't have both an href and a schema"/>
    </complexType>

    <!-- Simple Types -->
    <simpleType name="StepType">
        <restriction base="xsd:string">
            <enumeration value="START"/>
            <enumeration value="URL_FAIL"/>
            <enumeration value="METHOD_FAIL"/>
            <enumeration value="ACCEPT"/>
            <enumeration value="URL"/>
            <enumeration value="METHOD"/>
            <enumeration value="URLXSD"/>
            <enumeration value="REQ_TYPE"/>
            <enumeration value="REQ_TYPE_FAIL"/>
            <enumeration value="WELL_XML"/>
            <enumeration value="WELL_JSON"/>
            <enumeration value="CONTENT_FAIL"/>
            <enumeration value="XSD"/>
            <enumeration value="XPATH"/>
            <enumeration value="XSL"/>
            <enumeration value="HEADER"/>
            <enumeration value="HEADERXSD"/>
            <enumeration value="HEADER_ANY"/>
            <enumeration value="HEADERXSD_ANY"/>
        </restriction>
{'fraction_non_alphanumeric': 0.11340941512125535, 'fraction_numerical': 0.0087820970042796, 'mean_word_length': 1.5145723573590404, 'pattern_counts': {'":': 0, '<': 819, '<?xml version=': 2, '>': 819, 'https://': 0, 'lorem ipsum': 0, 'www.': 72, 'xml': 72}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3817935', 'n_tokens_mistral': 11783, 'n_tokens_neox': 10722, 'n_words': 2744}