Problems parsing, parsers disagree

Discussion in 'XML' started by Christophe Vanfleteren, Apr 18, 2004.

  1. 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
    Christophe Vanfleteren, Apr 18, 2004
    #1
    1. Advertising

  2. 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
    Chris Huebsch, Apr 18, 2004
    #2
    1. Advertising

  3. 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
    Christophe Vanfleteren, Apr 18, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=

    I completely disagree

    =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=, Jul 2, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    614
    Kevin Spencer
    Jul 6, 2004
  2. Replies:
    3
    Views:
    560
  3. Replies:
    6
    Views:
    576
    Roedy Green
    Oct 22, 2005
  4. Letbetter, Jason
    Replies:
    4
    Views:
    305
    yaipa h.
    Sep 10, 2003
  5. spectrallypure
    Replies:
    7
    Views:
    1,666
    Paul Jansen
    Jan 23, 2007
Loading...

Share This Page