468,510 Members | 1,852 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,510 developers. It's quick & easy.

Problems parsing, parsers disagree

Hello,

I'm parsing xml that is returned by the Amazon webservices (using their REST
interface).

Their dev-heavy.xsd has the following entry:

<xs:element name="Track">
<xs:complexType>
<xs:sequence>
<xs:element name="TrackName" type="xs:string" minOccurs="0"/>
<xs:element name="ByArtist" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Tracks">
<xs:complexType>
<xs:sequence>
<xs:element ref="Track" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

The xml that is returned contains the following for tracks:

....
<Tracks>
<Track>Son of Sam</Track>
<Track>Somebody That I Used to Know</Track>
<Track>Junk Bond Trader</Track>
....
</Tracks>

When I unmarchall the XML using Castor (which uses the Xerces parser), I get
a SaxException:

org.xml.sax.SAXException: Illegal Text data found as child of: Track
value: "Son Of Sam"

The xml I get returned also doesn't validate against the schema according to
the validator in the Netbeans IDE. The following error occurs:

cvc-complex-type.2.3: Element 'Track' cannot have character [children],
because the type's content type is element-only. [36]
But when I run xmllint from the commandline:

xmllint --schema http://xml.amazon.com/schemas3/dev-heavy.xsd amazon.xml

and validate against the schema, the xml validates allright.

If I replace the <Track> section with
<Track><TrackName></TrackName></Track>, I can parse it allright with
Castor.

Now what I want to know is, which parser is correct here? I always thought
that only the replaced form should parse.

--
Kind regards,
Christophe Vanfleteren
Jul 20 '05 #1
2 3684
Christophe Vanfleteren (Sun, 18 Apr 2004 08:14:56 GMT):
I'm parsing xml that is returned by the Amazon webservices (using their REST
interface).
[...]
If I replace the <Track> section with
<Track><TrackName></TrackName></Track>, I can parse it allright with
Castor.

Now what I want to know is, which parser is correct here? I always thought
that only the replaced form should parse.


xmllint is wrong.
Chris
--
Chris Huebsch www.hübsch-gemacht.de | TU Chemmnitz, Informatik, RNVS
GPG-Encrypted mail welcome! ID:7F2B4DBA | Str. d. Nationen 62, B204
Chemnitzer Linux-Tage 2005, 5.-6.März | D-09107 Chemnitz
http://www.tu-chemnitz.de/linux/tag/ | +49 371 531-1377, Fax -1803
Jul 20 '05 #2
Chris Huebsch wrote:
Christophe Vanfleteren (Sun, 18 Apr 2004 08:14:56 GMT):
I'm parsing xml that is returned by the Amazon webservices (using their
REST interface).


[...]
If I replace the <Track> section with
<Track><TrackName></TrackName></Track>, I can parse it allright with
Castor.

Now what I want to know is, which parser is correct here? I always
thought that only the replaced form should parse.


xmllint is wrong.


Ok, thanks, I'll file a bugreport with Amazon.

--
Kind regards,
Christophe Vanfleteren
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by YoBro | last post: by
8 posts views Thread by Gerrit Holl | last post: by
5 posts views Thread by Aleksandar Matijaca | last post: by
8 posts views Thread by pradeepsarathy | last post: by
reply views Thread by Divya Prakash | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.