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

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

Ah! 

When I move the namespace declaration to the Rule element:

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

then the errors went away.

I have never had to co-locate the namespace declaration like this. Should this  be considered a bug in the XML Schema validator that I am using?

/Roger 


-----Original Message-----
From: C. M. Sperberg-McQueen [mailto:cmsmcq@blackmesatech.com] 
Sent: Sunday, September 23, 2012 5:55 PM
To: Costello, Roger L.
Cc: C. M. Sperberg-McQueen; xmlschema-dev@w3.org
Subject: Re: XSD 1.1: not okay to have an xs:assert at the attribute level?


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 Monday, 24 September 2012 16:30:51 UTC