Hi all,
I have an element with an attribute typed as xs:string.  I want to write
a document where this attribute contains formatting characters such as
tab and linefeed.  When I go to write them out, they show up as
formatting in the resulting document, but they are not preserved when
read back in.  For example:

I write in my generated code:

Description d;
d.setValue("One\nTwo\nThree");

This looks like:

<Description value="One
Two
Three"/>

in the output, but it becomes "One Two Three" when read back in since
the whitespace is ignored, I assume.  I tried using the
setSaveSubstituteCharacters trick with XmlOptions, mapping newline,
carriage return and tab to HEXADECIMAL, but that's even worse; if I
pretty print, it turns all the pretty print tabs into hex codes, and
still doesn't affect attribute values, the only thing I actually want
escaped!  I tried escaping myself by grabbing the string before calling
setValue and using .replaceAll("\n" "&#xA;"), but XMLBeans outsmarts me
by escaping the ampersand, so the resulting file looks like:

<Description value="One&amp;#xA;Two&amp;#xA;Three"/>

which corrupts the value.  I guess if I could write the escaped string
directly to the file, that would work, but I feel like I can't be the
only one with this problem.  Maybe there's some XmlOptions setting I'm
missing?  Any assistance would be greatly appreciated.
-- 
Elias Holman
Stottler Henke Associates



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to