Thanks for the reply and for the pointer to path(). I ran a few tests and I think I could make that work.
Is this really the best way to approach this problem, though? I am not trying to be argumentative; I am just a little surprised because it was not what I was expecting.
This approach requires that I write a lot of
in several different handlers, which seems pretty high maintenance - if the structure of a Class element (for example) changes I have to make sure all of the handlers are changed appropriately.if( $child_of_some_element ) { # do this } elsif( $child_of_some_other_element ) { # do something else }
I was hoping there would be a way to approach this that is a little more OO-like, where the child element wouldn't have to know what the parent element was in order to do the Right Thing. Ideally, I'd like to think about parsing this file in chunks: parse Class elements this way, parse Attribute elements that way, etc, and each chunk (think "object") could have its own TaggedValue handler (for example).
Perhaps I am thinking about this in the wrong way and over-complicating matters, or my expectation for how to solve this problem is a Bad Idea.
Thoughts?
In reply to Re^2: Creating context-specific handlers in XML::Twig
by bobf
in thread Creating context-specific handlers in XML::Twig
by bobf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |