473,410 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

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 3830
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: YoBro | last post by:
Hi I have used some of this code from the PHP manual, but I am bloody hopeless with regular expressions. Was hoping somebody could offer a hand. The output of this will put the name of a form...
0
by: bugbear | last post by:
Subject pretty much says it all. I'd like to parse XML (duh!) using Xerces (because its fast, and reliable, and comprehensive, and supports lots of features). I'd like to conform to standards...
8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
5
by: Aleksandar Matijaca | last post by:
Hi there, I am in some need of help. I am trying to parse using the apache sax parser a file that has vaid UTF-8 characters - I keep end up getting a sun.io.MalformedInputException error. ...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
8
by: pradeepsarathy | last post by:
Hi all, Does the SAX parser has eventhandlers for parsing xml schema. Can we parse the xml schema the same way as we parse the xml document using SAX Parser. Thanks in advance. -pradeep
0
by: Divya Prakash | last post by:
Hi But I am unable to parse all the nodes of the tree .....especially the subtree of the main tree It displays only the sibling not the subtree Regards Divya
1
by: Sidhartha | last post by:
Hi, I am facing a problem while parsing local language characters using sax parser. We use DOM to parse and SAX to read the source. But when our application parses strings with local language...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.