Re: [XML-Twig] Problems with Newlines in print

Johannes Kilian <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Organization VITRONIC Dr.-Ing. Stein Bildverarbeitungssysteme GmbH
Message-ID <[email protected]>
Hi Mirod,

mirod schrieb:
> It would be easier if the snippet of code that you sent could actually
> run.
as I wrote in followup mail
* Trying to reproduce behaviour outside my script failed (yet) - but the
problematic XML-File is read and handled as shown in code snippet ...
I tried to isolate the causing code sequences to reproduce the behaviour
- but didn't succeed yet.

As the problem occurs only in context of my complete script, I could
send you the causing script and XML-Files as personal mail ...
But: The problematic XML is only in use within a short code sequence:
...
foreach my $currNodeActionItem (@nodesActionItems) {
...
     if ($destType =~ m{XPATH}igmx) {

                # Parse die Ziel-Datei als XML ....
                my $twigDest = XML::Twig->new(pretty_print =>
'indented', comments => 'keep', empty_tags => 'normal', keep_encoding =>
1, keep_atts_order => 1);
                $twigDest->parsefile($fnMod);

                # Modifiziere den Inhalt des Ziel-XPATH
                my @nodeListTmp;
                @nodeListTmp = $twigDest->find_nodes($dest);
                if (!@nodeListTmp) {
                  $logger->warn("XPath <" . $dest . "> does not exist in
destination <" . $fnModOrig . "> - skipping item ...");
                  next;
                }
                my $destVal = $nodeListTmp[0]->text;
                $logger->info("......Ersetze Zielwert <" . $destVal . ">
mit Quellwert: <" . $srcVal . ">");
                $nodeListTmp[0]->set_text($srcVal);

                $twigDest->print_to_file($fnMod);
    } ## end if ($destType =~ m{XPATH}igmx)
...
}

Nowhere else the $twigDest, which contains those new newlines, is used
within the script ...

> Barring that I can still give you some generic advice: if the input file is 
> already indented, could you try using the keep_spaces => 1 option instead of 
> pretty_print => 'indented'? That might help.
>   
Doing this, I got additionals newline after EACH line

<A>
  <B>
    <C>

grows up to (XXXXX indicating additionaly inserted lines) - not only
newlines within comments but everywhere

<A>
XXXXX
  <B>
XXXXX
    <C>
XXXXX
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.