Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: RFC: HTML::StripScripts::LibXML

by Moron (Curate)
on Jul 04, 2007 at 09:32 UTC ( #624852=note: print w/replies, xml ) Need Help??

in reply to RFC: HTML::StripScripts::LibXML

The context of this reply is I happened to write an XML code generator recently.

A1) XML is used for a wide variety of things so it's hard to say what options should be included. And the options I tend to put in a code generator may not be very 'normal', but FWIW here they are based on just two market data applications I had to support with an XML code generator (amazing how detailed applications can get!) - the options I went for happen to answer some of your other questions, but my idea was to write a complete callback-driven parser and generator - different goal!

- whether or not to generate opening tags for tags excluded by other options ('other options' including those handled in a different method or module)

- whether or not to generate closing tags for tags excluded by 'other options'

- whether or not to generate subtags (as opposed to relying on callback functionality to do it).

- whether or not to generate values for non-nested tags (as opposed to letting callback functionality do it).

- I use a separate trivial method for putting the XML version line - but that therefore functions as an option to do so or not.

- I use $$_ as the default output buffer (by ref) but allow it to be optuionally overridden with another scalar reference

- By default no filehandle to write to but one may be passed as an option.

- I have optional tag introducer (by default empty but some XML standards need e.g. a '- ' in front of tags.

- max depth of tag introducer.

- two options for to setting min and max tag nesting depth at which code is generated by default (because callbacks may or may not be used to specifically generate code).

- a callback all option, a code reference for execution for all tags.

- callback by tag nesting depth options ('user' can specify same or different code references for different depths).

Instead of just a tag callback by name I have:

- callback before opening a tag by name

- callback after opening a tag by name

- callback before closing a tag by name

- callback after closing a tag by name

- optional unit tabbing string for output, default "\t" - I use the x operator to multiply the tabbing string by current depth - 1.

A2) I can't see the functionality of output_text - I have in its place an outer method called puttag that uses a separate recursive tree traversing method rather than a manual stack.


^M Free your mind!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://624852]
[choroba]: Re: Modern Perl 4th Edition Perl Cookbook is a very bad cookbook, I wasn't able to finish any dish and the resulting meals were disgusting.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-11-17 21:30 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (272 votes). Check out past polls.