[jdom-interest] Automatic Character Escaping

Jay Balunas balunasj at netscout.com
Tue Apr 1 15:27:09 PST 2003


Robert Munro,

      Thanks for your quick response.  I did try what you suggested with:

>You need to put a
>non-breaking space, character code 160 into JDOM.

I entered   instead, because that is what actually gets replaced with
the DTD in the XML.  This had a very similar effect where I was getting
 .  Is there another way to get that string into it.

On your other point I have been looking at the XMLOutputter class (as well
as just about every other class) and do see the escaping code there.  I am
also seeing this behavior with the JDOMSource objects.  I am using the
JDOMSource object for transforming with Xalan and the result contains the
same " " characters.

Thanks for any further thoughts you might have.

Jay





                                                                                                                                
                      "Robert (Jamie)                                                                                           
                      Munro"                   To:       Jay Balunas/NetScout at NetScout                                          
                      <rjmunro at arjam.ne        cc:                                                                              
                      t>                       Subject:  RE: [jdom-interest] Automatic Character Escaping                       
                                                                                                                                
                      04/01/2003 01:06                                                                                          
                      PM                                                                                                        
                                                                                                                                
                                                                                                                                





> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Jay Balunas
> Sent: 01 April 2003 17:30
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] Automatic Character Escaping
>
>
> This is probably an easy one, but I have been looking through the
achieves
> for a similar issue and have not been able to find one.
>
> I need to get "&nbsp;" into the text of some of my elements (for HTML
> decimal alignment and such) and the various outputters are automatically
> changing it to be "&amp;nbsp;".  I have a .dtd defined that contains the
> entity listing for the "&nbsp;", but it does not seem to be used.  I have
> also tried to directly add an EntityRef object but that does not
> seem to be
> working.
>
> I just need a way for JDOM to not do the automatic escaping for this
> character sequence.

When you put &nbsp; as text in a JDOM object, you are putting the
characters
ampersand, "n", "b", "s", "p" and semicolon into the XML. You can't "stop
it
being escaped". It is not "escaped" it just is. You need to put a
non-breaking space, character code 160 into JDOM.

JDOM doesn't escape characters, it always stores them literally. It is only
XMLOutpputer that escapes them when it converts them to XML. JDOM and XML
are different ways of storing data. It just happens that they can store the
same data, and tools to convert between the two are provided.

Robert Munro








More information about the jdom-interest mailing list