[xsd-users] Preserve newline characters

Boris Kolpackov boris at codesynthesis.com
Wed Oct 21 07:56:30 EDT 2009


Hi Keith,

Wire, Keith C <keith.c.wire at lmco.com> writes:

> I have very large strings in my XML files.  There are numerous newlines 
> and tabs in the text itself to organize the data.  It appears that when 
> codesynthesis is parsing the xml the newlines are being removed.  Is there 
> any way to maintain them (I didn't see anything in the documentation)?  
> Is this a codesynthesis issue or a Xerces-C issue?

Whitespace handling depends on the XML Schema type used for an element or
attribute. xsd:string preserves all whitespaces. xsd:normalizedString
performs whitespace normalization, that is, tabs, newlines, etc., are
replaced with spaces. Then there is xsd:token which, besides performing 
normalization, also performs whitespace collapsing, that is, replacing
all continuous spaces with a single space and removing leading and
trailing whitespaces.

So if you want to preserve all whitespaces in your text then you need to 
use xsd:string. Which type are you using?

Boris



More information about the xsd-users mailing list