xmlgraphics-fop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damien Gardner <dgard...@itdesign.ie>
Subject Re: SAX exception with '&' char
Date Fri, 19 Jan 2001 15:14:33 GMT
At 19/01/01 14:59 Friday, you wrote:

>In order to create a PDF file, I use a xml file coming from
>an other source and look like this :
><TAG>mon texte avec accent &agrave; pour tester</TAG>
>or like this :
><TAG>The society Marcel & Co</TAG>
><TAG>The society Marcel &Co</TAG>
>The problem appears with the '&' char. So is there any
>solution to get the text between the tag, without any text
>modification because we don't create this file ?
>We must handle any of these cases.
>Here are the corrresponding exceptions :
>org.xml.sax.SAXParseException: The entity "agrave" was
>referenced, but not declared.
>org.xml.sax.SAXParseException: The entity name must
>immediately follow the '&' in the entity reference.
>org.xml.sax.SAXParseException: The reference to entity "Co"
>must end with the ';' delimiter.

None of the examples you provide are well-formed XML so
they cannot be parsed. For the first, you need a DTD
that defines the "agrave" entity, as this is not one of
the predefined entities in XML. For the second, you
must use:

<TAG>The society Marcel &amp; Co</TAG>

and for the third:

<TAG>The society Marcel &amp;Co</TAG>

While you don't create the file, you might request that
you be sent well-formed XML. If there are errors in what
is sent to you, you can only complain to the sender, or
fix the errors in their XML.

It may be that the originators of the documents do not
know their HTML from their XML. The entity "agrave" is
valid in HTML as is the use of the ampersand (&) as shown
but neither are valid in XML.

It's a bit like being sent Java code with syntax errors
in it and then trying to find a compiler that won't
complain about them and will magically figure out what
the code was meant to be. You will just have to modify
the code to fix it or write your own parser!


To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org

View raw message