[xsd-users] Preserve newline characters

Wire, Keith C keith.c.wire at lmco.com
Wed Oct 21 11:05:03 EDT 2009


I unfortunately do not get to control this schema, but they are using xsd:string.  I used a debugger to look at the string as soon as the generated classes are used to extract the parsed data, as well as a print statement.  Both show none of the newlines.  I'm using XSD 3.2.0 and cxx-tree.  Any ideas on what I could try would be appreciated.

Thanks,

Keith

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Wednesday, October 21, 2009 5:57 AM
To: Wire, Keith C
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Preserve newline characters

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