Re: phantom attribute?

Eric Sirois <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
  Hi David,

Which version of Java are you using? Which distribution - Sun, IBM or 
Oracle?

Not sure what Oracle uses as an XML parser. IBM uses Xerces. Newer 
versions of Sun JDK (1.5 and 1.6) use a version Xerces. If it's an older 
version of Sun JDK (1.4 or older), then it might be using the old 
Crimson parser.

Kind regards,
Eric

On 9/29/2010 6:52 PM, David McBride wrote:
> 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:[email protected]]
> Sent: Wednesday, September 29, 2010 2:10 PM
> To: David McBride
> Cc: [email protected]
> 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.
>>
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.856 / Virus Database: 271.1.1/3166 - Release Date: 09/29/10 01:37:00
>
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.