Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Vertical Tab (\x0b) in XML::LibXML 'XML::LibXML'->new( qw/ recover 2 / )->load_xml

by choroba (Canon)
on Jul 23, 2014 at 22:15 UTC ( #1094856=note: print w/ replies, xml ) Need Help??


in reply to Re: Vertical Tab (\x0b) in XML::LibXML 'XML::LibXML'->new( qw/ recover 2 / )->load_xml
in thread Vertical Tab (\x0b) in XML::LibXML

That's not my problem. I need to generate well-formed XML that can be loaded by other tools, too. Some of them don't use XML::LibXML nor Perl.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re^2: Vertical Tab (\x0b) in XML::LibXML 'XML::LibXML'->new( qw/ recover 2 / )->load_xml
Re^3: Vertical Tab (\x0b) in XML::LibXML
by Anonymous Monk on Jul 23, 2014 at 22:50 UTC

    So if you make two passes through libxml you get valid xml? But then you lose the vertical tab ...

    If I try using toFile I get  error : xmlEscapeEntities : char out of range

    Error seems to be coming from libxml2 itself ... this says sanitize your inputs first so ascii control chars aren't in there :/

    I'd report it to XML::LibXML maintainer , for the clues he might provide :)

      So if you make two passes through libxml you get valid xml?
      No. I make one pass and use something (libxml in this case) to parse the result. If a result was produced, I'd expect the second tool to accept it.

      Sanitizing input seems reasonable, but for such a complex data format, something like

      $text = 'XML::LibXML::Text'->removeInvalidChars($str, $version)
      would be handy.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        No. I make one pass ... removeInvalidChars

        Um,

        sub XML::LibXML::Node::toSanitaryString { my( $node ) = @_; return 'XML::LibXML'->new( qw/ recover 2 / ) ->load_xml(string => $node->toString )->toString; }
        All that is left is to supress the "xmlEscapeEntities : char out of range" warning toSanitaryString generates

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1094856]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2015-07-04 23:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls