Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Error parsing data (SAXParser) containing ampersand (&)

Thread view: 
kebabkongen@hotmail.com - 23 Oct 2006 09:08 GMT
Hi,
I am trying to parse some data which is edited with a rich text editor
(FCKeditor)

When I se scandinavian characters, they are converted to html encoded
version by the FCK editor
For example:
"Å" becomes "Å"
"Ø" becomes "Ø"
etc

This content is then sent to the SAX parser as a StringBuffer (sr):
mySaxParser.parse( new InputSource( sr), this);

But with the scandinavian characters I get parsing errors. The input
string:
"Å test"
is converted to
"Å test"
by the FCK editor
And then I get this error from the SAX parser:
WARNING: error parsing text: Å test
org.xml.sax.SAXParseException: The entity "Aring" was referenced, but
not declared.

Is there perhaps some way I should escape the ampersand character?
Or what can I do with the data in the StringBuffer above so that the
parsing will work fine?

Regards, PML
kebabkongen@hotmail.com - 23 Oct 2006 09:17 GMT
Hi again,
I've registered a couple of problems with my post:
(the html coding was rendered as the HTML output, not as the code I
wrote... ;) )

It was supposed to be:

<pre>

"Å" becomes "&Aring"
"Ø" becomes "&Oslash"
etc

...and...

But with the scandinavian characters I get parsing errors. The input
string:
"Å test"
is converted to
"&Aring; test"
by the FCK editor
And then I get this error from the SAX parser:
WARNING: error parsing text: &Aring; test

</pre>

BTW: this is weird;
in preview mode, the post looks fine, but when posted, it seems as if
the coding is rendered as HTML instead as the code I see in preview
mode...
Could it be a bug in google groups? Or how should you post HTML source
code without it being rendered?

Regards, PML
kebabkongen@hotmail.com - 23 Oct 2006 09:20 GMT
...not again...?

Tring once more:

"Å" becomes "&amp;Aring;"
"Ø" becomes "&amp;Oslash"
etc

...and...

But with the scandinavian characters I get parsing errors. The input
string:
"Å test"
is converted to
"&amp;Aring test"
by the FCK editor
And then I get this error from the SAX parser:
WARNING: error parsing text: &amp;Aring; test
org.xml.sax.SAXParseException: The entity "Aring" was referenced, but
not declared.

-PML
Tor Iver Wilhelmsen - 23 Oct 2006 16:34 GMT
> org.xml.sax.SAXParseException: The entity "Aring" was referenced, but
> not declared.

You need to tell SAX to ignore unknown entities by adding a handler
for them and let the handler just put the unparsed entity onto
whatever destination you output to. Look at the DTDHandler interface.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.