wood burning stoves*
The moose likes XML and Related Technologies and the fly likes XML parser skips mutiple whitespaces while parsing a xml list element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML parser skips mutiple whitespaces while parsing a xml list element" Watch "XML parser skips mutiple whitespaces while parsing a xml list element" New topic
Author

XML parser skips mutiple whitespaces while parsing a xml list element

bhavana radhakrishnan
Greenhorn

Joined: Sep 06, 2009
Posts: 1
<p>I have a list like {“A”,””,”C”}.I serialise it into a text file as a xml list element . The serialized string turns out to be “A C” (two spaces between A and C)
<p>But XML SAX parser parses it to “A C” with a single space between them(consolidates mutiple spaces to one space)
<p>In my program I take the parsed string(A C) and apply a java split function on it. It gives me a list {"A","C"} .The empty space has been dropped.
<br>
After i did some googling i found that
<ol>
<li>XML SAX parser parses:
All non-space characters (tab and new-line) are translated into a space character, and all multiple space characters are consolidated
into a single space.</li>
<li>And also The restriction <whitespace value=”preserve”> which is the support given by the XML to preserve whitespaces will work only on the string based elements and not on <xsd:list> element</li>
</ol>
<p>
Can you please confirm whether the above information is correct?Is there any parser setting to preseve the mutiple whitespaces in a list element while parsing. I am using a Xerces SAX parser.
<p> My work is held up cause of this issue. Can anyone please help out?
<p>Thanks in advance!
 
Consider Paul's rocket mass heater.
 
subject: XML parser skips mutiple whitespaces while parsing a xml list element