You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Anthony Rabaa <ar...@amconresearch.net> on 2003/07/15 19:45:06 UTC

SAX Parser & Entity Expansion

Hello,

I'm using a SAX parser to scan incoming XML and for select structures, 
build a DOM for manipulation.  I've run into a little snag when it comes 
to the incoming entities being expanded into thier characters and I was 
wondering if somebody could tell me what property or feature would 
disable entity expansion?

A good example is <para>&lt;graphic&gt;</para> in the SAX parser funnels 
into the DOM builder as <para><graphic></para> which throws a parser 
error.  The EntityResolver class is for external entities so the SAX 
parser will not relay the requests to it.  Thanks in advance for your help!
-- 

   *Anthony Rabaa*
   Software Developer
   AMCon Research Inc., Ottawa, Ontario, Canada
   http://www.amconresearch.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: SAX Parser & Entity Expansion

Posted by Andy Clark <an...@apache.org>.
Anthony Rabaa wrote:
> I'm using a SAX parser to scan incoming XML and for select structures, 
> build a DOM for manipulation.  I've run into a little snag when it comes 
> to the incoming entities being expanded into thier characters and I was 
> wondering if somebody could tell me what property or feature would 
> disable entity expansion?
> 
> A good example is <para>&lt;graphic&gt;</para> in the SAX parser funnels 
> into the DOM builder as <para><graphic></para> which throws a parser 
> error.  The EntityResolver class is for external entities so the SAX 
> parser will not relay the requests to it.  Thanks in advance for your help!

Conformant XML parsers will always expand those entities
out to their text value. While you can't turn this off,
Xerces does have a feature that controls whether the
parser reports these built-in entity refs. Then you can
write a SAX filter that looks for the start/end of these
entities and pass them through to the output in their un-
expanded form while ignoring the expanded content.

Does that make sense?

Take a look in the documentation under "Features" to find
the setting(s) that you want to turn on.

-- 
Andy Clark * andyc@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org