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:
<la>rare</la> before the 20th century.
<la>rare</la> after the 18th century.
In both these cases, for checking purposes the sense or entry should be treated as "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:
sub la_obs_handler { my ($t,$elt) = @_; my $la = $elt->text; my $isNow = 0; if ( ($prev && $prev->text =~ m/[nN]ow $/) || $elt->parent->text =~ m/[nN]ow .* and rare/ || $elt->parent->text =~ m/rare after/ || $elt->parent->text =~ m/rare before/ ) { $isNow = 1; } if ( $la eq "rare" && ! $isNow ) { $is_entry_rare = 1; } }
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?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |