jcupp has asked for the wisdom of the Perl Monks concerning the following question:
For generating new documents, it can follow a minimum "style", that is, the minimum elements, tags, etc. to be valid. Telling it what paths to follow and what attributes to insert is done by passing it various hashrefs and arrayrefs, giving the parser what it needs to follow the winding path of the schema...
The template is generated using callbacks to access attribute values and paths to follow from these LOLs, and also puts in warnings if something was required by the schema...
Does something like this exist? Or would it be useful to anybody else? I use it to automate the generation of valid documents using simpler data structures, building templates for quick rendering (www), and building objects that contain these hashrefs and arrayrefs that tell how to render a document based on the schema.
For me, it's a nice way to turn an XML based API I'm working with into a set of easy-to-use methods in objects that can quickly generate small-to-large XML fragments & documents. For example (a random API):
Becomes:<request user='xxx' password='yyy'> <put_document id='aaa'> <document>foooooooooooo</document> <thumbnail>iuayrejhfuieayd374jhudfajh</thumbnail> ...
Always valid, based on a schema...$api->put_document ({user=>'xxx', password=>'yyy',document=>'... etc.. +. });
|
|---|