I wouldn't use a hash for this application, I'd use objects. I needed something like this for
XML::Validator::Schema's simple type library. In XML Schema, simple types are defined as a tree where each child node adds restrictions and inherits the behavior of its parent. I modeled this tree as a hash of objects which track their parent through composition.
For example, to instantiate the entry for nonPositiveInteger I call the derivation constructor (dervive()) on the integer object and then add a new restriction (that the value can't be greater than 0):
$BUILTIN{nonPositiveInteger} = $BUILTIN{integer}->derive(name => 'no
+nPositiveInteger');
$BUILTIN{nonPositiveInteger}->restrict( maxInclusive => 0 );
You can see this code here: XML::Validator::Schema::SimpleType. I've found this to be an easy to maintain system which has grown smoothly as new types have been added by myself and others. It also makes supporting custom simple-types created by schemas easy.
-sam
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.