472,791 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 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 3800
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.