From ffb0397721a50682b2fc54f53ea6bf94937b21c8 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 16 Apr 2009 22:12:47 +0200 Subject: documentation, and a few author-tests --- Makefile.PL | 2 + lib/Tree/Transform/XSLTish.pm | 103 +++++++++++++++++++++++++- lib/Tree/Transform/XSLTish/Context.pm | 10 +++ lib/Tree/Transform/XSLTish/Transformer.pm | 119 ++++++++++++++++++++++++++++++ lib/Tree/Transform/XSLTish/Utils.pm | 11 +++ t/00-author-deps.t | 6 ++ t/00-author-pod-cover.t | 7 ++ t/00-author-pod.t | 6 ++ 8 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 t/00-author-deps.t create mode 100644 t/00-author-pod-cover.t create mode 100644 t/00-author-pod.t diff --git a/Makefile.PL b/Makefile.PL index 5f0c3d4..8912266 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -6,9 +6,11 @@ all_from 'lib/Tree/Transform/XSLTish.pm'; requires 'Tree::XPathEngine' => 0, 'Moose' => 0, + 'Class::MOP' => 0, 'Params::Validate' => 0, 'Carp::Clan' => 0, 'Sub::Exporter' => 0, + 'MooseX::AttributeHelpers' => 0, ; test_requires 'Test::Most' => 0, diff --git a/lib/Tree/Transform/XSLTish.pm b/lib/Tree/Transform/XSLTish.pm index e754cd0..2176aea 100644 --- a/lib/Tree/Transform/XSLTish.pm +++ b/lib/Tree/Transform/XSLTish.pm @@ -6,6 +6,7 @@ use Params::Validate ':all'; use Tree::Transform::XSLTish::Utils; use Tree::Transform::XSLTish::Transformer; use Carp::Clan qw(^Tree::Transform::XSLTish); +use v5.8; our $VERSION='0.1'; @@ -40,7 +41,7 @@ sub tree_rule { }); # TODO at least one of 'name' and 'match' must be specified - # TODO default priority mased on match + # TODO default priority based on match my $store=Tree::Transform::XSLTish::Utils::_rules_store(scalar caller); @@ -117,6 +118,8 @@ Transforming an HTML document: use strict; use warnings; + engine_class 'XML::XPathEngine'; + default_rules; tree_rule match => 'img[@alt="pick"]', action => sub { @@ -124,13 +127,12 @@ Transforming an HTML document: }; package main; - use XML::XPathEngine; use HTML::TreeBuilder::XPath; my $tree=HTML::TreeBuilder::XPath->new(); $tree->parse_file('mypage.html'); - my $trans=HtmlTransform->new(engine=>XML::XPathEngine->new()); + my $trans=HtmlTransform->new(); my ($image_srce)=$trans->transform($tree); =head1 DESCRIPTION @@ -153,6 +155,101 @@ that are compatible with the XPath engine; for example, L if you use L, or L if you use L. +=head1 EXPORTS + +=head2 C + + tree_rule match => '//node_name', + priority => 1, + action => sub { ... }; + +This is the basic fuction to declare a transformation rule; it's +equivalent to the C