Qualified attributes and attribute references in schemas

I have an odd situation with my IDE (oxygenXML) and I can't tell if its a
problem with my schema or the IDE (well the xml parser used by the IDE). As
an example, I have the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schema.foo.net/bar"
  attributeFormDefault="unqualified" xmlns:b="http://schema.foo.net/bar">
  <xs:attribute name="foo" type="xs:string"/>
  <xs:element name="element">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="b:element"/>
      </xs:choice>
      <xs:attribute ref="b:foo"/>
      <xs:attribute name="bar" type="xs:string"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

What I'm expecting is nested element tags each with optional foo and bar
attributes. I created the following document:

<?xml version="1.0" encoding="UTF-8"?>
<element xmlns="http://schema.foo.net/bar"
  <element foo="bar" bar="foo"></element>
</element>

When I validate this against the schema above, I get the following error:
    Attribute 'foo' is not allowed to appear in element 'element'.

If I do:
<b:element xmlns:b="http://schema.foo.net/bar">
  <b:element b:foo="bar" bar="foo"/>
</b:element>

All is forgiven and it passes validation.

As far as I can read in Eric Meyer's book the form should follow the default
set in the root xs:schema element.

So which is right?

Adam

Received on Wednesday, 21 July 2004 17:20:42 UTC