Re: XML::Rules tagspec
"Jenda Krynicky" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
From: Terrence Brannon <[email protected]> > 1 - perhaps you could use a few more head sections to break up the docs > under 'The Rules'. =head3 tag spec = head3 action > > and then several =head4 for each action so they can be seen from the TOC. Done. Will be in the upcoming version. > 2 - but anyway I'm wondering why you cant select tags based on > attributes of the tag. And also why you cant provide a subref here that > returns true for tags matching its tests. In others, > HTML::Element::look_down can find tags by 'tagspec', but it can also > easily do various attribute tests and if that's not enough, use a sub ref. > > The reason I mention it, is that you could have two table tags in a > document and have different rules for processing each: > > sub my_table_1 { > $self->gi eq 'table' and $self->attr('table_number') == 1 > } > > my $tagspec = \&my_table_1 I would like to keep it simple. If you need to do a test like this, you can do it within the rule. You have access both to the list of enclosing tags and their attribute hashes. table => sub { if ($_[1]->{table_number} == 1) { ... } else { ... } }, Which is also why I include the implementations next to the builtin rules in the docs. So that you could easily write a subroutine rule that tests whatever you want and then does the same as one of the builtin rules. Jenda ===== [email protected] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs