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 ying lcs <yi...@gmail.com> on 2008/02/19 06:20:31 UTC

Configure xerces to accept '&' character

Hi,

In my xml file, it has something like this:
<fullscreen>/FLVPlayer.swf?xml=/play_flash_xml.php?id=308088&fs=true</fullscreen>

so when i use xerces to parse the file, I got exception like this:
org.xml.sax.SAXParseException: The reference to entity "fs" must end
with the ';' delimiter.
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

Is there a way to configure xerces to accept '&' in the text node ,
instead of changing the source to use '&amp;' in the text node?

I have no control of the source, so i need to make xerces to accept '&' .

Thank you for any idea.

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


Re: Configure xerces to accept '&' character

Posted by Mukul Gandhi <ga...@gmail.com>.
To introduce ampersand character in the text node, it must be written as &amp;

If you write something as, ... &fs ... then &fs is interpreted as
entity reference (and the entity must be defined somewhere). That's
how the XML spec defines the language.

On Feb 19, 2008 10:50 AM, ying lcs <yi...@gmail.com> wrote:
> Hi,
>
> In my xml file, it has something like this:
> <fullscreen>/FLVPlayer.swf?xml=/play_flash_xml.php?id=308088&fs=true</fullscreen>
>
> so when i use xerces to parse the file, I got exception like this:
> org.xml.sax.SAXParseException: The reference to entity "fs" must end
> with the ';' delimiter.
>        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>
> Is there a way to configure xerces to accept '&' in the text node ,
> instead of changing the source to use '&amp;' in the text node?
>
> I have no control of the source, so i need to make xerces to accept '&' .
>
> Thank you for any idea.



-- 
Regards,
Mukul Gandhi

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


Re: Configure xerces to accept '&' character

Posted by "Eric J. Schwarzenbach" <Er...@wrycan.com>.
If you really can't force the source of your documents to give you 
correct XML, and you know for sure every & is meant as a literal & and 
is not part of some actual entity reference, you could simply a custom 
implementation of java.io.FilterInputStream that replaces every & with 
&amp. Then wrap the incoming stream with your custom stream before 
feeding it to Xerces.

Eric

ying lcs wrote:
> Hi,
>
> In my xml file, it has something like this:
> <fullscreen>/FLVPlayer.swf?xml=/play_flash_xml.php?id=308088&fs=true</fullscreen>
>
> so when i use xerces to parse the file, I got exception like this:
> org.xml.sax.SAXParseException: The reference to entity "fs" must end
> with the ';' delimiter.
> 	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>
> Is there a way to configure xerces to accept '&' in the text node ,
> instead of changing the source to use '&amp;' in the text node?
>
> I have no control of the source, so i need to make xerces to accept '&' .
>
> Thank you for any idea.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>   

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


Re: Help with predefined entities and character references

Posted by "T.A. Nguyen" <ta...@cnconsulting.com>.
Just escape the & and that should do it.

Regards,
T.A. Nguyen
http://themilli.com/ta

  ----- Original Message ----- 
  From: Huynh, Lynn T. 
  To: j-users@xerces.apache.org 
  Sent: Thursday, February 21, 2008 2:43 PM
  Subject: Help with predefined entities and character references 


  Hi,
  I am using SAX and have the need to have the predefined entities and the character references to be unparsed.  
  For example if I have this string:   &amp; &lt; &#x3E; &#62;
  I would like to get:    &amp; &lt; &#x3E; &#62; 
  and not:    & < > >  

  I know I can turn on on the features to notify the character references and builtin references and do my own handling, but is there any other option to make this easier?
  Thanks in advance for your help.

Re: Help with predefined entities and character references

Posted by ke...@us.ibm.com.
If you're working with XML tools, these entity references and numeric
character references WILL be expanded.

If that isn't what you intended, your document should have escaped the &
character.


______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)

Help with predefined entities and character references

Posted by "Huynh, Lynn T." <ly...@unisys.com>.
Hi,
I am using SAX and have the need to have the predefined entities and the
character references to be unparsed.  
For example if I have this string:   &amp; &lt; &#x3E; &#62;
I would like to get:    &amp; &lt; &#x3E; &#62; 
and not:    & < > >  
 
I know I can turn on on the features to notify the character references
and builtin references and do my own handling, but is there any other
option to make this easier?
Thanks in advance for your help.
 

Re: Configure xerces to accept '&' character

Posted by ke...@us.ibm.com.
In XML, a stand-alone & character must be escaped to keep it from being
interpreted as introducing an entity reference or numeric character
reference. See http://www.w3.org/TR/xml/#syntax

Fix your input document.

______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)