[XML-SIG] PrettyPrint

Anders Bruun Olsen anders@bruun-olsen.net
Tue, 17 Dec 2002 17:31:50 +0100


On Tue, Dec 17, 2002 at 04:54:30PM +0100, JS wrote:
> I've got the following problem:
> If I save the following xml file using PrettyPrint()
> <?xml version="1.0"?>
> <doc><raw><![CDATA[foo]]></raw><raw>bar</raw></doc>
>  I get:
> ##################PrettyPrint
> <?xml version='1.0' encoding='UTF-8'?>
> <doc>
>   <raw>
>     <![CDATA[foo]]>
>   </raw>
>   <raw>bar</raw>
> </doc>
> Now next time I read in the xml, a new text node is created in the DOM tree 
> due to the indent an newline behind the first <raw> element.
> I could use Print since it doesn't add any additional data. But Pretty is more 
> pretty ;-)
> I'm not sure about ignorable whitespace in xml, but I think, it is not 
> correct.
> Shouldn't the output be ...<raw><![CDATA[foo]]></raw>...?

I haven't tried this myself, but it sounds like what you are looking for
is a normalize function - that way you should be able to rid yourself of
the extra whitespace and linebreaks.

Please correct me if I am wrong :)

-- 
Anders
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/O d--@ s:+ a-- C++ $UL+++ P++ L+++ E- W+ N(+) o K? w O- M-- V
PS+ PE@ Y+ PGP+ t 5 X R+ tv+ b+ DI+++ D+ G e- h !r y?
------END GEEK CODE BLOCK------
PGPKey: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8BFECB41