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

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 UTC