> The non-pathological representation would have: $hash{$key}=[$value1, $value2, $value3,...] and the distinction between array and scalar fields would be handled by the schema.
I don't understand what you want or mean, sorry.
Could you give me an example of a non trivial XML with a reversable mapping to a nested perl data structure?
For my amateur understanding each XML-tag is from a perl perspective a hash with attributes as keys additionally to tag name and an ordered list of children tags. And the list part can only be represented as an array or a scalar if it's just one element (like a text-string).
The example you gave in the OP is only a special case of a simple schema, where "key" was the tag-name and "value" was a (one element) string.
For sure many DTDs might be much easier - or in your word "non-pathologically" - represented, but thats the general case we are talking about.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.