[jdom-interest] Line feed parsing

Gordon, Simon Simon.Gordon at galileo.com
Tue Dec 11 15:08:09 PST 2001

If you need to pass line-feeds or other non-valid XML characters** from
application to application, you should use some form of encoding like
BASE64. However, I would suggest moving this to element data so that the
encoding used can be passed as an attribute. For example:-

<tag encoding="BASE64">ABCJDHFkdhewncSJDJ</tag>
<tag encoding="TEXT">No non-XML characters in here</tag>

rather than using a variant of the attribute name to signal the encoding:-

<tag description_BASE64="ABCJDHFkdhewncSJDJ">
<tag description_TEXT="No non-XML characters in here"/>

** XML character data is defined (section 2.4) as "any string of
characters...". See section 2.2 for the definition of a character and
section 2.3 for whitespace. Section 3.3.3 is where attribute value
normalization is described.

-----Original Message-----
From: Jason Hunter [mailto:jhunter at acm.org]
Sent: Monday, December 10, 2001 2:39 PM
To: Li Zhao
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Line feed parsing

That's behavior mandated by the XML spec.  Check the section on
attribute whitespace normalization.


Li Zhao wrote:
> Not quite familiar with jdom, need some help from you
> experts. I have a probolem for outputting: There is an
> attribute value, which is taken from a TextArea with
> line feed ("Test\nGood"). The line feed seems not
> converted properly, because what I see in the XML file
> is something like
> <tag>xmi.id="_1.2" description="Test
> Good"/>
> Should the line feed be converted to something like
> "&#10;" ?. Because when it is read back, the line feed
> is replaced with a white space and it becomes "Test
> Good".
> Any ideas? Thanks in advance.
> Jack
> __________________________________________________
> Do You Yahoo!?
> Send your FREE holiday greetings online!
> http://greetings.yahoo.com
> _______________________________________________
> To control your jdom-interest membership:
To control your jdom-interest membership:

The information in this electronic mail message is sender's business
Confidential and may be legally privileged.  It is intended solely for the
addressee(s).  Access to this Internet electronic mail message by anyone
else is unauthorized.  If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be taken
in reliance on it is prohibited and may be unlawful. 
The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message and
its attachments could have been infected during  transmission. By reading
the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. Cendant Corporation is not liable for any loss or damage
arising in any way from this message or its attachments.

More information about the jdom-interest mailing list