OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: [xml-dev] entity references for special characters and the Sax parse

[ 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. &amp;), 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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS