W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2010

RE: phantom attribute?

From: David McBride <dmcbride@codeaurora.org>
Date: Wed, 29 Sep 2010 15:52:21 -0700
To: "'Noah Mendelsohn'" <nrm@arcanedomain.com>
Cc: <xmlschema-dev@w3.org>
Message-ID: <000001cb6028$fa065b30$ee131190$@org>
I'm using the javax and org.xml.sax java classes.  Specifically, I'm using
DocumentBuilder to parse the XML.

Weirdly, though, I also created a perl test harness
(XML::Validator::Schema), which does not throw the exception, even though
both are supposedly W3C compliant.

David

-----Original Message-----
From: Noah Mendelsohn [mailto:nrm@arcanedomain.com] 
Sent: Wednesday, September 29, 2010 2:10 PM
To: David McBride
Cc: xmlschema-dev@w3.org
Subject: Re: phantom attribute?

David:  I don't have an answer, but I suspect it would help if you 
indicated which parser you used, and any other such details that might 
affect what you're seeing.  Thank you.

Noah

On 9/29/2010 3:48 PM, David McBride wrote:
> 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.
>
Received on Wednesday, 29 September 2010 22:58:43 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:18 UTC