Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: twig_print_outside_roots replaces " with &quote; and ' with '

by dimitarsh1 (Novice)
on Nov 30, 2016 at 15:43 UTC ( [id://1176942]=note: print w/replies, xml ) Need Help??


in reply to twig_print_outside_roots replaces " with &quote; and ' with '

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

Replies are listed 'Best First'.
Re^2: twig_print_outside_roots replaces " with &quote; and ' with &apos;
by Anonymous Monk on Dec 02, 2016 at 08:22 UTC
    What is wrong with the first version output, it didn't convert any & or '" to entities , so its working, right?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2025-11-11 19:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.