You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Th...@emc.com on 2009/12/14 22:08:01 UTC

whitespace management with DOM element

Hello,

 

We use both xerces-c and xerces-j in our product.  I have an element
that usually contains alpha characters, but depending upon the user
input can contain a single space.  I'm using the DocumentBuilderFactory
to create an instance of DocumentBuilder, and then generating DOM
elements from that and serializing the output to a file.

 

I'm seeing the resulting serialized file is simply an empty XML element.
Is it possible to configure the DOM builder to preserve the spaces if
they exist, or does this go against the XML spec?  If so, can you help
me understand how to make that happen?

 

I could modify the writing and parsing of the element to always add some
additional characters (such as quotes), but that doesn't seem like an
elegant solution and the resulting data then has the additional
characters.  As a test and not a desired solution, I also tried
performing a string replacement of space characters with   but the
ampersand was replaced with the entity &.

 

Thanks for the guidance on how to handle elements that could have just
whitespace.

 

Regards,

Nicholas