|The stupid question is the question not asked|
XML:: Twig - can you check for text following the element being handled?by mertserger (Curate)
|on Nov 08, 2011 at 15:27 UTC||Need Help??|
mertserger has asked for the
wisdom of the Perl Monks concerning the following question:
As I have posted before, I help maintain a set of Perl scripts which use XML::Twig to run validation checks on dictionary entries written in XML. The checks are looking for things that a DTD would not spot.
In Node XML::Twig prev_sibling I asked for help with a piece of code which decided whether a sense in the entry was to be considered rare or not.
Now I have a further problem relating to this issue: there is another piece of text which might mean that something labelled "rare" in an la element is actually not rare:
The piece of code I posted in the previous question I have been able to modify to handle this as it is handling the parent element of the <la> element. This code is called at the sense level within the XML.
Howevere there is other fairly similar code to handle things for the entry as a whole:
This should set the variable $is_entry_rare to 1 if the <la> element being handled contains the text "rare" but not if it is also preceded by "Now" or "Now <something> and". This works. However it should also not set the varaibale to 1 if the la element is followed by sibling text saying "after ...." of "before ...." I have tried testing the parent node's text content as shown in my code but it does not seem to work - I think this is because XML::Twig has not accessed anything following the <la> element since it is handling that element.
Is there any way of getting at the text following the <la> element? I know I could do this by handling the parent element instead but I don't think that is an option with my legacy code. Are any other solutuions possible?