My attempt to post this on the REXML JitterBug failed (which is probably
just as well as I learned one more tidbit since that attempt.
Basically, I would like to have pretty printing on as well as
transitive. I see in the rexml_stable todo that this has been crossed
off, and isn’t mentioned in the main branch page either.
The write() method for CData nodes ignores the transitive flag. This
snippet of code illustrates the example:
The extra spaces before the start of the CDATA node change what
the actual document contains rather than just its presentation.
I’m not actually sure why the line is being split on the pretty print
(that started happening when I began passing transitive as true, which
is what I wasn’t doing when I tried to submit the issue on Jitterbug).
Is this something that is possible to fix? Or has it been deemed
unworthy? If so, does anyone have a workaround? Right now I’ve just
shut pretty printing off. This is undesirable since there are many
occasions when the output will be viewed and/or edited by hand after output.
The write() method for CData nodes ignores the transitive flag. This
snippet of code illustrates the example:
This is fixed; it’ll be in CVS before the end of the day, and will be
in REXML 3.0.7.
CData is supposed to ignore the transitive flag, but other things were
occurring that caused errors and other misformattings. CData sections
will not be formatted, because they “raw” data, and whitespace in
CData sections is always significant. Therefore, REXML will not add
whitespace to CData sections; also, since the “magical” markup of the
CData end, namely “]]>” is a block of characters, we can’t apply the
normal trick of inserting a CR before the close ‘>’. The only place
to insert whitespace would be before the “]]>” (which would be adding
whitespace to the CData section, which is illegal), or after the
“]]>”, which would add a Text node to the tree, which would be illegal
for transitive documents.
Therefore, the XML document:
<a><![CDATA[ Lalalala ]]></a>
will be transitively printed as:
<a
><!CDATA[ Lalalala ]]></a
>
Which is about as good as we can get. This is still better than what
REXML was doing before, which was crashing :-).