On 09/22/2011 06:47 PM, Mark Tilford via RT wrote:
Show quoted text> Thu Sep 22 12:47:00 2011: Request 71164 was acted upon.
> Transaction: Ticket created by ralphmerridew@gmail.com
> Queue: XML-Twig
> Subject: discard_spaces being ignored
> Broken in: 3.38
> Severity: Normal
> Owner: Nobody
> Requestors: ralphmerridew@gmail.com
> Status: new
> Ticket<URL:
https://rt.cpan.org/Ticket/Display.html?id=71164>
>
>
> If the XML contains whitespace at certain spots, it won't pretty-print.
> Isn't the discard_spaces option supposed to prevent that?
>
> To trigger error, run script as attached.
> To prevent, change the 1 to a 0.
>
> perl v.5.12.2, MSWIN32-x86-multi-thread
That's the normal behavior: your xml boils down to
'<d><para>p 1</para> <para>p 2</para></d>', which as the same structure
as, for example, '<p><b>Hello</b> <i>World!</i></p>', where obviously
you would not want to discard the space between b and i.
The space would be discarded if it included a \n, try with
<d><para>p 1</para>\n <para>p 2</para></d>
The documentation is unclear about this, so I have updated it in the
development version of the module.
i have also added a 'discard_all_spaces' option, that discards spaces
more aggressively, namely it will discard all-space strings before a tag
(opening or closing), whether they include a \n or not. This would allow
indenting of your document.
The development version is in the usual places,
http://xmltwig.org/xmltwig/ and
http://github.com/mirod/xmltwig
--
mirod