|We don't bite newbies here... much|
Re: RFC: HTML::StripScripts::LibXMLby Moron (Curate)
|on Jul 04, 2007 at 09:32 UTC||Need Help??|
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!