[
Lists Home |
Date Index |
Thread Index
]
> > Has anyone else used the Sax parser to parse a given
> XML file with the Java method
> > <saxParser>.parse(<filename>)? If I call this with a file
> that has an ampersand in it (e.g. &), the rest of the
> > text within that value on either side of the special
> character will be cut off (I verified this by seeing what appears
> > in the "characters" method). Has anyone else observed this
> behavior?
When a SAX parser calles the characters() method in your ContentHandler, it
can break up the text node into as many pieces as it likes, calling the
method once for each piece. It looks as if Xerces is breaking the text at
entity boundaries, which is a perfectly reasonable thing to do. It's the job
of your ContentHandler to re-assemble the pieces.
There are SAX filters around that do this for you but I can't lay my hands
on one immediately (the one in Saxon does too many other things for it to be
useful to you).
Mike Kay
|