phantom attribute?

"David McBride" <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <001301cb600f$4b744c80$e25ce580$@org>
I'm seeing some odd behavior when I parse XML with the schema that I just
developed.  In particular, there are two elements, 'signal' and 'method',
which may contain an element, 'arg'.  In the case of 'method', the element
'arg' may have a 'direction' attribute.  However, in the case of 'signal',
the 'arg' element may NOT have a 'direction' attribute.

 

I've represented this in my schema, as follows:

 

<xs:complexType name="signal_arg_type">

                                <xs:sequence>

                                                <xs:element
maxOccurs="unbounded" minOccurs="0" ref="annotation"/>

                                </xs:sequence>

                                <xs:attribute ref="name"/>

                                <xs:attribute name="type"
type="arg_and_property_type" use="required"/>

                </xs:complexType>

 

                <xs:complexType name="method_arg_type">

                                <xs:attribute ref="name"/>

                                <xs:attribute name="type"
type="arg_and_property_type" use="required"/>

                                <xs:attribute default="in" name="direction"
type="arg_direction"/>

                </xs:complexType>

 

<xs:element name="method">

                                <xs:complexType>

                                                <xs:choice
maxOccurs="unbounded" minOccurs="0">

                                                                <xs:element
maxOccurs="unbounded" minOccurs="0" ref="annotation"/>

                                                                <xs:element
maxOccurs="unbounded" minOccurs="0" name="arg" type="method_arg_type"/>

                                                </xs:choice>

                                                <xs:attribute ref="name"
use="required"/>

                                </xs:complexType>

                </xs:element>

 

                <xs:element name="signal">

                                <xs:complexType>

                                                <xs:choice
maxOccurs="unbounded" minOccurs="0">

                                                                <xs:element
maxOccurs="unbounded" minOccurs="0" name="arg" type="signal_arg_type"/>

                                                                <xs:element
maxOccurs="unbounded" minOccurs="0" ref="annotation"/>

                                                </xs:choice>

                                                <xs:attribute ref="name"
use="required"/>

                                </xs:complexType>

                </xs:element>

 

 

Strangely enough, when I parse XML with signal elements, I end up with
SAXParseExceptions that say that the 'arg' element in 'signal' is not
allowed to have a 'direction' attribute, even though the xml that caused the
exception does not contain the 'direction' attribute!!  For example, here is
one of the elements that causes the exception:

 

<signal name="DeviceAdded">

      <arg name="udi" type="s"/>

 </signal>

 

As you can see, there's no 'direction' attribute.  How is it possible that
my parser could be throwing these exceptions, given the schema that I
described above?!  

 

Thanks, in advance, for any feedback.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.