[cxml-devel] CDATA doesn't preserve whitespace

Sunil Mishra smishra at sfmishras.com
Sat Sep 16 15:48:17 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi David,

Thanks for the clarification. I didn't notice that CDATA wasn't being
output.

I'll try the non-canonical mode.

Sunil

David Lichteblau wrote:
> Quoting Sunil Mishra (smishra at sfmishras.com):
>> CL-USER(116): (dom:map-document (cxml:make-namespace-normalizer
>> (cxml:make-octet-stream-sink *standard-output*)) *)
> 
> Note that make-octet-stream-sink defaults to canonical mode for
> historical reasons.
> 
>> <svg xmlns="http://www.w3.org/2000/svg">
  <script
>> type="text/css">
    
    
    
  </script>
</svg>
>> #<MULTIVALENT stream socket connected from localhost/3813 to
>>   localhost/3817 @ #x205003d2>
> 
> Sorry, I don't see a bug.  The serializer in canonical mode outputs
> character references for the newlines here, but it doesn't output a
> CDATA section either in the first place, so that's fine.
> 
> If you want to see a CDATA section, use non-canonical mode:
> 
> cl-user(43): (dom:map-document
>               (cxml:make-octet-stream-sink *standard-output* :canonical nil)
>               (cxml:parse-file "~/graph.xml" (cxml-dom:make-dom-builder)))
> <?xml version="1.0" encoding="UTF-8"?>
> <svg>
>   <script type="text/css">
>     <![CDATA[
>      
>     ]]>
>   </script>
> </svg>
> 
>> ``Within a CDATA section, only the CDEnd string is recognized as markup,
>> so that left angle brackets and ampersands may occur in their literal
>> form; they need not (and cannot) be escaped using "<" and "&".
>> CDATA sections cannot nest.''
>>
>> Can cxml please correctly follow this requirement?
> 
> It follows this requirement while parsing.
> 
> Only in serialization there is one little "problem" (unrelated to your
> question):
> 
> A document constructed in memory might include a CDATA section with
> characters not representable in a CDATA section.  That is a user error,
> and CXML should signal an error when told to serialize such a document
> in non-canonical mode; right now I believe it does not signal that error
> and outputs the user data as-is, resulting in output that isn't
> well-formed.  (But I'm taking patches. :-))
> 
> 
> d.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFDBzBjRnqWMAEf1cRAtCQAJ9+607cS8f7Ve7tSd+vWSVCnp1uWgCgv1cs
cYhvYSemUAH6RVlE3T1kEjU=
=PINa
-----END PGP SIGNATURE-----



More information about the cxml-devel mailing list