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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.