Howdy Monks,
not that I'd want to dump my XML::Rules, but there is another idea that might help a bit using XML::Simple. One of the things that makes using the XML::Simple produced datastructure harder is inconsistency. Unless you specify otherwise you may once find the key "foo" pointing to a single value or single hash and other time to an array of values or hashes. Based on whether it was encountered once or more times in the parent node. So you want to use ForceArray to make sure it's always array ... but would you want to use it for all tags? Including those that may only appear once in the parent node according to the DTD or schema? Probably not. So why not have a tool that extracts the list of tags that may be repeated from the DTD/Schema?
Another common inconsistency is the handling of tag content. If the tag has no attributes you get tagname => 'value', if it does you get tagname => {attr=> 1, content => 'value'}. So if you have a tag that sometimes does have attributes and sometimes does not you have to test whether you've got a hashref or a plain scalar. Or you can turn on ForceContent and get a hash for all. Including the ones that may never have any attributes or child nodes.
So I wonder whether there'd be any interest in 1)extending XML::Simple so that ForceContent accepts a list of tags just like ForceArray does and 2) either extend XML::Simple or provide a tool to generate the lists of tags that can be repeated for ForceArray and those that may have both attributes and content for ForceContent.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Simple, ForceArray, ForceContent and DTD/Schema
by ikegami (Patriarch) on Nov 17, 2006 at 21:17 UTC | |
by Jenda (Abbot) on Nov 17, 2006 at 21:42 UTC | |
by samtregar (Abbot) on Nov 18, 2006 at 20:18 UTC | |
|
Re: XML::Simple, ForceArray, ForceContent and DTD/Schema
by GrandFather (Saint) on Nov 17, 2006 at 21:15 UTC | |
|
Re: XML::Simple, ForceArray, ForceContent and DTD/Schema
by wazoox (Prior) on Nov 20, 2006 at 17:07 UTC | |
|
Re: XML::Simple, ForceArray, ForceContent and DTD/Schema
by Penfold (Novice) on Nov 20, 2006 at 14:28 UTC |