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.


In reply to XML::Simple, ForceArray, ForceContent and DTD/Schema by Jenda

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.