Re: [xml] [BUG?] Global attribute declaration in schema is not used at root node


On Wed, 2005-11-30 at 16:42 +0100, Dominique Quatravaux wrote:
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="";><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=""; 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="";
  <!-- "floating" attribute -->
  <xsd:attribute name="id" type="xsd:ID"/>
  <!-- Bogus elements -->
  <xsd:element name="foo">

Note that this complexType has no attribute declared.

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


The behaviour of the schema processor looks correct.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]