Two Laptop Bag
The moose likes XML and Related Technologies and the fly likes Don't turn & to & Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Don Watch "Don New topic

Don't turn & to &

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
For reasons way to strange to explain, we get XML from a web service, parse via SAX, regenerate a subset of the XML to a string, then pass that to JAXB.
The web service sends us ampersands, like in company names, as +amp; which is wonderful. The SAX parser delivers this to us in chars() as a normal ampersand. We put that into the regenerated XML and the JAXB parser croaks. We should be putting +amp; back in there.
Actually, we fixed this for +amp; And the next special character that blew up, and the next one. Now I'd like to do one of two things:
* Definitively fix all charcters that can possibly cause trouble.
* Tell the SAX parser the first time around to stop converting +amp; to &
The second is cleaner, of course. Any ideas how to do that? Or a complete list of special chars?
Edited to put + for ampersand cause HTML browser was fixing it again. Dang. Also I found the five predefined general entities in the XML docs so I'm more confident of our fix on the fly solution, even though I still don't like it much.
[ July 09, 2003: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Don't turn & to &
It's not a secret anymore!