Well, this isn't a simple question, because you are presenting a design issue more than a coding issue.

There are essentially two issues here:

  1. Parse/process the XML into an internal structure that can be evaluated against the rules
  2. Express the rules in such a fashion that lends itself to a clean machine-evaluation implementation

It's not clear from your explanation whether you are evaluating an entire XML document at once, against a set of rules, or whether you are evaluating a series of structures out of a document in sequence. That is, is the XML just a layer around a series of RDBMS records, or is it more structured than that?

I'm inclined to suggest that you use a SAX-based approach to managing the XML itself. If you are testing multiple data-sets from the same file, it will be easy to associate that action with the end of the appropriate element. And if not, you can still build the data structure in whatever way suits you. XPath may be a useful alternative, but like I said it's difficult to say since I'm not clear on all the specific needs you have.

As to the part where you actually evaluate the rulesets against the data, that too depends a lot on what you are trying to accomplish and what information you have to work with when setting up the system. In you example, it looks like token-replacement, probably based on the name of the tag used to mark-up the data. That's why I wonder if this is just XML sugar-coating of RDBMS data, because it's overkill if that is the case. You may be doing a lot more work than you need to be. The named-token syntax doesn't appear to have any allowance for the structure of the XML document itself-- what if <state> occurs as a tag at different levels, with different significance at each?

If you can reduce the rule-evaluation problem to a matter of input data coming in to the rule in a hash table or some other keyed-reference structure, then create a rule engine to evaluate against this types of inputs, you should be OK. Then it's just a matter of turning the XML input into an appropriate hash-table.

Good luck. Sorry this wasn't more definitive, but the problem itself is a little loosely defined.

--rjray

Referenced CPAN modules:


In reply to Re: XML Process Engine by rjray
in thread XML Process Engine by Anonymous Monk

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.