SAX parser ignores part of XML document

P

Per Magnus L?vold

Hi, all!
I have a XML Parsing based on oracle's SAX parser
(oracle.xml.parser.v2.SAXParser).
With some XML files, it works fine. However, a more simple XML file
will not be processed. The parser stops after processing a small part
of the document, and ignores the rest. Is there anything I can do to
make the parser "accept" this document? Changing the structure of the
XML file is not an alternative..

Here is an extract from my XML file:
<Products>
<Product>
<IM>Flamingo</IM>
<PDUK>19981231</PDUK>
<PRUKS>1.00</PRUKS>
<AVUK>IN</AVUK>
<DNUK>HarperCollins Distribution Services</DNUK>
</Product>
<Product>
<IM>McGraw-Hill Education</IM>
<BIC>UHD</BIC>
<RC>U</RC>
<RC>P</RC>
<RC>R</RC>
<PDUK>19871231</PDUK>
<AVUK>IN</AVUK>
<DNUK>McGraw-Hill Education - Europe</DNUK>
</Product>

The first startElement() event I get is for the "Product" element. It
seems as if the parser ignores the "Products" element. Then, after
endElement for the first "Product" element, the parser stops.

Seems as if it beleives that "Product" is the first element! Is there
anything I can do to make the parser continue to parse the rest of the
document?

Regards, PML
 
J

John C. Bollinger

Per said:
Hi, all!
I have a XML Parsing based on oracle's SAX parser
(oracle.xml.parser.v2.SAXParser).
With some XML files, it works fine. However, a more simple XML file
will not be processed. The parser stops after processing a small part
of the document, and ignores the rest. Is there anything I can do to
make the parser "accept" this document? Changing the structure of the
XML file is not an alternative..

Here is an extract from my XML file:
<Products>
<Product>
<IM>Flamingo</IM>
<PDUK>19981231</PDUK>
<PRUKS>1.00</PRUKS>
<AVUK>IN</AVUK>
<DNUK>HarperCollins Distribution Services</DNUK>
</Product>
<Product>
<IM>McGraw-Hill Education</IM>
<BIC>UHD</BIC>
<RC>U</RC>
<RC>P</RC>
<RC>R</RC>
<PDUK>19871231</PDUK>
<AVUK>IN</AVUK>
<DNUK>McGraw-Hill Education - Europe</DNUK>
</Product>

The first startElement() event I get is for the "Product" element. It
seems as if the parser ignores the "Products" element. Then, after
endElement for the first "Product" element, the parser stops.

Seems as if it beleives that "Product" is the first element! Is there
anything I can do to make the parser continue to parse the rest of the
document?

I note that the extract you have provided is not well-formed. Perhaps
that's just a cut&paste error; it should in any case not prevent a SAX
parser from generating a startElement() event for <Products>. In order
to tell you much more I would need to see your code for instantiating
and configuring the parser, for setting up the input, and for performing
the parse. Have you configured an ErrorHandler? If so, then have you
checked whether it reports any errors / warnings? If not then you
really should do.


John Bollinger
(e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top