optional attribute

Hi,

If I have the following schema:

<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:complexType name="test-type">
              <xs:attribute name="optional-attribute" type="xs:string"
use="optional"/>
              <xs:attribute name="required-attribute" type="xs:string"
use="required"/>
              <xs:attribute name="prohibited-attribute" type="xs:string"
use="prohibited"/>
         </xs:complexType>
     <xs:element name="test-element" type="test-type"/>
</xs:schema>

and derive the following XML document from it:

<?xml version="1.0" encoding="UTF-8"?>
<test-element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="D:\XML\test-of-optionality.xsd"
optional-attribute="" required-attribute="test" prohibited-attribute="test"/>

then Spy (version 4.4) tells me that:

   * I MUST fill in a string in the 'optional-attribute', which doesn't make
     sense to me, because that means that my application has to remove all
     non-filled-in optional attributes from the XML document (then Spy accepts
     the file as valid)
   * I may not fill in a string in the 'prohibited-attribute', which makes sense

Is that removal of unused optional attributes what XML Schema prescribes, or is
it a flaw of Spy?

Regards,
Hans

Received on Tuesday, 18 November 2003 10:15:41 UTC