- From: Costello, Roger L. <costello@mitre.org>
- Date: Sun, 23 Sep 2012 15:33:13 +0000
- To: Mukul Gandhi <gandhi.mukul@gmail.com>
- CC: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hello Mukul, > <xsd:assert test="string(@name) eq 'xsd:element'" /> That's a good idea, but the value of @name is not a string, it is a QName. Thus, I should be able to change the namespace prefix: <xsd:assert test="string(@name) eq 'xs:element'" /> and the assertion should still work. /Roger -----Original Message----- From: Mukul Gandhi [mailto:gandhi.mukul@gmail.com] Sent: Sunday, September 23, 2012 11:12 AM To: Costello, Roger L. Cc: xmlschema-dev@w3.org Subject: Re: XSD 1.1: not okay to have an xs:assert at the attribute level? 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:33:40 UTC