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: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Sun, 23 Sep 2012 15:54:54 -0600
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-Id: <49DA0912-9824-4E1F-A882-C31E7DFC9FEA@blackmesatech.com>
To: "Costello, Roger L." <costello@mitre.org>

On Sep 23, 2012, at 5:55 AM, Costello, Roger L. wrote:

> ...
> 
> 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

Do you still get those errors if you copy the namespace declaration
for 'xsd' onto the Rule element?

Bear in mind that the document instance against which assertions are
checked is rooted at the element whose assertions are being checked:
that is, the assertion for Rule is being checked in a document whose root
element is Rule, not Test.

Without checking the details of the rules for constructing an XDM from
a PSVI, I do not know whether (under the rules as currently specified in 
XSD 1.1 Structures section 3.13.4.1 and in the XDM spec) the Rule 
element in the XDM constructed for checking assertions is required to, 
allowed to, or forbidden to have a namespace binding for 'xsd'.  Even if
a careful reading of the rules shows that it's allowed or required to have
such a binding, I can imagine that initial implementations of assertions
might overlook the case.  (You're building an XDM instance from a 
PSVI whose root element has no namespace attributes but has a 
non-empty [in-scope namespaces] property, which will never happen in
a normal XML-derived infoset; it's easy to see how code to build the XDM
might not check for that logically inconsistent case.)

> 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?

I'm guessing it's because in your input the namespace attribute is on Test, not
Rule.

> 
> 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.

Both assertions are associated with complex types; both complex types are bound to
elements.  There's no "attribute level" assertion in either of your cases.

I hope this helps.

-- 
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************
Received on Sunday, 23 September 2012 21:55:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 23 September 2012 21:55:17 GMT