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

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

From: Mukul Gandhi <gandhi.mukul@gmail.com>
Date: Sun, 23 Sep 2012 20:41:59 +0530
Message-ID: <CABuuzNMX3-g8-DOuSSW_DRK49+EccLRRo12WMBcNS-8PW359ng@mail.gmail.com>
To: "Costello, Roger L." <costello@mitre.org>
Cc: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hi Roger,
   I observe following results with Xerces XSD 1.1 validator:

I get a 'false' <assert> result, with the way you've specified the
first variant of your assertion (i.e, an <assert> failure similar to
Saxon. but not the namespace prefix error).

When I change the assertion to following,

<xsd:assert test="string(@name) eq 'xsd:element'" />

then this works for me. I feel, this might solve your use case.

On Sun, Sep 23, 2012 at 5:25 PM, Costello, Roger L. <costello@mitre.org> wrote:
> 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
>



-- 
Regards,
Mukul Gandhi
Received on Sunday, 23 September 2012 15:12:54 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 23 September 2012 15:12:54 GMT