W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2012

XSD 1.1: not okay to have an xs:assert at the attribute level?

From: Costello, Roger L. <costello@mitre.org>
Date: Sun, 23 Sep 2012 11:55:32 +0000
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <B5FEE00B53CF054AA8439027E8FE17751E65F755@IMCMBX04.MITRE.ORG>
Hello Folks,

For this XML document:

<Test xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Rule name="xsd:element" />
</Test>

I want an xs:assert element to test that the name attribute has the QName value xsd:element

I placed the xs:assert inside the element declaration for Rule:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    
    <xsd:element name="Test">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Rule" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="name" type="xsd:QName" use="required" />
                        <xsd:assert test="@name eq xsd:QName('xsd:element')" />
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    
</xsd:schema>

I validated the XML document using SAXON 9.4 and got these two errors:

(1) Namespace prefix {xsd} has not been declared

(2) Element Rule does not satisfy assertion @name eq xsd:QName('xsd:element')

I don't understand those errors. Clearly xsd has been declared and clearly Rule satisfies the XPath expression.

Note that when I move the xs:assert up a level:

    <xsd:element name="Test">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Rule" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="name" type="xsd:QName" use="required" />
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
            <xsd:assert test="Rule/@name eq xsd:QName('xsd:element')" />
        </xsd:complexType>
    </xsd:element>

then I get no error.  

Why is this?

Is it not okay to have an xs:assert at the attribute level? If so, would you please refer me to the section in the specification that says this.

/Roger
Received on Sunday, 23 September 2012 11:55:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 23 September 2012 11:56:00 GMT