You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Randall J. Parr" <RP...@TemporalArts.COM> on 2000/11/14 02:26:13 UTC

How access text using SAX without translating > to < ?

I am parsing documents containing rows to be inserted in a database
table.

I am using SAX for speed and to limit memory useage (the files are 100M
files).

The text that makes up the data for a column may contain XML/HTML markup
which I wish to preserve and insert into the database. I've already
taken care of finding "embedded" elements and inserting them into the
text but I can't seem to figure out how to capture the text content
WITHOUT having entities such as &amp; converted to &.

The end result is I'm trying to make sure the data I insert into the
database columns is well-formed XML/XHTML.

Thanks

R.Parr
TemporalArts



Re: How access text using SAX without translating > to < ?

Posted by Neil Graham <ne...@jtcsv.com>.
Hi Randall,

I don't think there's any way to stop an XML parser from normalizing
entities like &amp;.  The easiest way around this might be to "nest" the
entity references; that is, to have &amp;amp; instead of &amp; in the
input text.  If you have the former, the XML parser should normalize the
string to &amp;, which is what you want.  &gt; would then be &amp;gt; in
your input file.  

If you can't control the input file directly, you could try writing a
simple filter to transform entity references in the file you're
presented with into this nested form.  If you make a good filter, this
shouldn't add much time to the processing of each document.  

Hope that helps,
Neil Graham

"Randall J. Parr" wrote:
> 
> I am parsing documents containing rows to be inserted in a database
> table.
> 
> I am using SAX for speed and to limit memory useage (the files are 100M
> files).
> 
> The text that makes up the data for a column may contain XML/HTML markup
> which I wish to preserve and insert into the database. I've already
> taken care of finding "embedded" elements and inserting them into the
> text but I can't seem to figure out how to capture the text content
> WITHOUT having entities such as &amp; converted to &.
> 
> The end result is I'm trying to make sure the data I insert into the
> database columns is well-formed XML/XHTML.
> 
> Thanks
> 
> R.Parr
> TemporalArts
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org