Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Dear all,

Thank you for sharing you opinion and about this issue and giving ideas how to tackle this issue. The problem is that, printing what is outside the roots I have no control of (or at least I haven't found a good method). What I mean is that for the roots I can write a handler that will modify the output in whatever way I want (e.g., what @kcott suggest). This I cannot do for the outside of the root.

Furthermore, if I implement a handler that reads the style (which is what is actually outside of the the roots and I don't what to deal with) and simply prints it, it will be just fine.

Here is a sample input:

<style type="text/css"> @font-face { font-family: 'MyFont'; src: url('http://mywebsite/fonts/MyFont.otf'); } </style> <div> This is a test. Let's go. This is a brand name: 'D&G'. And this is + "a test". </div>

Here are the two example scripts and output:

my $t= XML::Twig->new( twig_print_outside_roots => 1, twig_roots => {'div' => sub { my ( $t, $e ) = @_; print STDOUT $e->text; $t->purge; }, 'style' => sub { my ( $t, $e ) = @_; $e->print(); $t->purge; } }, keep_atts_order => 1, );

and

my $t= XML::Twig->new( twig_print_outside_roots => 1, twig_roots => {'div' => sub { my ( $t, $e ) = @_; print STDOUT $e->text; $t->purge; }, }, keep_atts_order => 1, );

And this is the output from the first and then from the second version of the script.

<html><head></head><body>´&#9559;&#9488;<style type="text/css"> @font-face { font-family: 'MyFont'; src: url('http://mywebsite/fonts/MyFont.otf'); } </style> This is a test. Let's go. This is a brand name: 'D&G'. And thi +s is "a test". </body></html>

And

<html><head></head><body>´&#9559;&#9488;<style type="text/css"> @font-face { font-family: &apos;MyFont&apos;; src: url(&apos;http://mywebsite/fonts/MyFont.otf&apos;); } </style> This is a test. Let's go. This is a brand name: 'D&G'. And thi +s is "a test". </body></html>

Than's a lot. Greetings,
Dimitar


In reply to Re: twig_print_outside_roots replaces " with &quote; and ' with &apos; by dimitarsh1
in thread twig_print_outside_roots replaces " with &quote; and ' with &apos; by dimitarsh1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found