fgDOMWRTFormatPrettyPrint: not all that pretty

"Richardson, Steven" <[email protected]> Mon, 31 Oct 2005 10:19:55 -0500
Newsgroups gmane.text.xml.xerces-p.devel
Message-ID <[email protected]>
Hi:
 
I'm trying to write a DOM tree to a file using the DOMWriter object and I'm not having total success with the fgDOMWRTFormatPrettyPrint feature.
 
I get a strange mix of leading spaces and/or tabs on some lines that throw off the "pretty" alignment.
 
Here's basically what I'm doing:

sub writeDocument
{
    my($doc, $file) = @_;
 
    my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
 
    my $writer = $impl->createDOMWriter();

 

    if($writer->canSetFeature("$XML::Xerces::XMLUni::fgDOMWRTFormatPrettyPrint", 1))
    {
        $writer->setFeature("$XML::Xerces::XMLUni::fgDOMWRTFormatPrettyPrint", 1);
    }
 
    if($writer->canSetFeature("$XML::Xerces::XMLUni::fgDOMWRTWhitespaceInElementContent", 1))
    {
        $writer->setFeature("$XML::Xerces::XMLUni::fgDOMWRTWhitespaceInElementContent", 1);
    }
 
    my $target = XML::Xerces::LocalFileFormatTarget->new($file);
                                
    $writer->writeNode($target, $doc);
 
    return;
}


Steven Richardson          Sonus Networks 
www.sonusnet.com          The Voice of the New Public Network 
732-625-3003  x233