Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: xml::twig and stylesheets

by mirod (Canon)
on Mar 23, 2006 at 05:49 UTC ( [id://538655]=note: print w/replies, xml ) Need Help??


in reply to Re^2: xml::twig and stylesheets
in thread xml::twig and stylesheets

Now you are entering the dark realm of comments and processing instructions before and after the root... be afraid, very afraid!

The answer: you have to replace the paste by $twig->_add_cpi_outside_of_root( leading_cpi => $xsl);. Which I agree is slightly weird, not to mention totally undocumented.

This might actually be worth a method of its own. What about add_stylesheet( $stylesheet_url )?

Replies are listed 'Best First'.
Re^4: xml::twig and stylesheets
by Tanktalus (Canon) on Mar 23, 2006 at 14:57 UTC

    Stylesheets aren't the only thing I've seen outside of root. To be honest, the way that rogue90 showed is the most intuitive manner to me. If XML::Twig could detect that the request is before the root AND the request is for a comment or a processing instruction, then just call the _add_cpi_outside_of_root function. Or if the request is after the root AND the request is for a PI, then do the same. (Comments after root allowed? I'm not sure.)

    Having an add_stylesheet method would then merely be a convenience method to wrap all that up. But it wouldn't limit the user to just one type of PI outside of root.

    Note that the way I've done this type of thing in the past is to read the XML file, add <root>...</root> tags around it, do my massaging, and then return $twig->root()->sprint($t->root(), 1) to get rid of the actual root tags. That can be ugly, too ;-)

      If XML::Twig could detect that the request is before the root AND the request is for a comment or a processing instruction, then just call the _add_cpi_outside_of_root function. Or if the request is after the root AND the request is for a PI, then do the same. (Comments after root allowed? I'm not sure.)

      It makes sense, I'll do just that (yes comments are allowed after the root, it's in the first production rule in the spec, the Misc after the element).

Re^4: xml::twig and stylesheets
by rogue90 (Novice) on Mar 23, 2006 at 14:54 UTC
    hmm.. I don't have that method in the version I am using which I can't change. I found _add_prolog_data which I am attempting to use now but no luck as of yet. A method for adding stylesheets would be quite useful. My other option it seems is to create the prolog myself by removing it from the twig altogether. Thanks much for your help.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-29 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found