Hi,

On Wed, 2005-11-30 at 16:42 +0100, Dominique Quatravaux wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Dear libxml hackers,
> 
> I am by no stretch enlightened in XML schemas, but I'm seeing a
> behavior that very much looks like a bug in libxml2's w3c-schema
> validator. I'm using version 2.6.22 on Debian sarge.
> 
> I believe the two XML files below should both validate, but only
> ok.xml actually does. Rationale: "free" attribute declarations (here
> the id attribute) are available to all elements, or so I thought.
> 
> == ok.xml ==
> 
> <foo xmlns="http://example.com/xsd/ns";><bar id="abc"/></foo>

This instance is valid, because <foo> has no attributes -
as declared - and the type of <bar> defaults to xs:anyType,
which accepts any content and any attributes 'laxly'; 'laxly'
means that if an element or attribute declaration is found
for a child element or an attribute node respectively, then
those nodes are validated against those declarations, if no
declarations are found, the validation is simply skipped.

> 
> == notok.xml ==
> 
> <foo xmlns="http://example.com/xsd/ns"; id="abc"><bar /></foo>

This instance is not valid, because the complexType you declared
for the <foo> element does not declare any attribute, thus
must not have any attributes.

> 
> == schema.xml ==
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>             targetNamespace="http://example.com/xsd/ns";
>             elementFormDefault="qualified"
>             attributeFormDefault="qualified">
>   <!-- "floating" attribute -->
>   <xsd:attribute name="id" type="xsd:ID"/>
>   <!-- Bogus elements -->
>   <xsd:element name="foo">
>     <xsd:complexType>

Note that this complexType has no attribute declared.

>        <xsd:sequence>
>       <xsd:element minOccurs="0" maxOccurs="1" name="bar" />

Note that the type of the local element declaration "bar"
defaults to xs:anyType.
You'll find the definition for xs:anyType at:
http://www.w3.org/TR/xmlschema-1/#d0e9252

>        </xsd:sequence>
>     </xsd:complexType>
>   </xsd:element>
> </xsd:schema>

The behaviour of the schema processor looks correct.

Regards,

Kasimier


_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to