ddascalescu@gmail.com via RT wrote:
Show quoted text> <URL:
http://rt.cpan.org/Ticket/Display.html?id=17064 >
>
> Speaking of things before root, I noticed in all versions, including
> this latest development one, that you have no control over the
> whitespace between the DOCTYPE and the root element, even with
> keep_spaces => 1.
>
> my $twig = XML::Twig->new(keep_spaces => 1)->parse('<!DOCTYPE xliff
> PUBLIC "-//XML-INTL
> XLIFF-XML 1.0//EN" "file:xliff.dtd">
>
>
> <root></root>')->print;
>
>
> # The CR/LFs before <root> won't be printed.
>
> Could this maybe be addressed? In my application, it would be nice to
> output the whitespace exactly as it was read.
Short answer: probably not.
Long answer: those line returns are not sent to the character handler,
like data within the root element, but rather to the default handler (of
XML::Parser). It looks like it would be a little difficult to figure out
which data should be kept with the root element, and which is part of
the doctype/dtd. I might try, but this is not very high on my priority
list ;--(
BTW, there was indeed a problem with flush-ing comments/pi's after (and
before!) the root element, it is fixed in the latest dv version (dated
Wed Jan 18 11:33:45 2006).
--
Michel Rodriguez
Perl & XML
xmltwig.com