summaryrefslogtreecommitdiff
path: root/lib/Tree/Transform/XSLTish/Transformer.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Tree/Transform/XSLTish/Transformer.pm')
-rw-r--r--lib/Tree/Transform/XSLTish/Transformer.pm23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/Tree/Transform/XSLTish/Transformer.pm b/lib/Tree/Transform/XSLTish/Transformer.pm
index d5ad6ec..16e27bd 100644
--- a/lib/Tree/Transform/XSLTish/Transformer.pm
+++ b/lib/Tree/Transform/XSLTish/Transformer.pm
@@ -1,14 +1,11 @@
package Tree::Transform::XSLTish::Transformer;
use Moose;
-use MooseX::AttributeHelpers;
use Moose::Util::TypeConstraints;
-use Params::Validate ':all';
use Tree::Transform::XSLTish::Utils;
use Tree::Transform::XSLTish::Context;
-use Tree::XPathEngine;
use Carp::Clan qw(^Tree::Transform::XSLTish);
-our $VERSION='0.2';
+our $VERSION='0.3';
subtype 'Tree::Transform::XSLTish::Engine'
=> as 'Object'
@@ -19,18 +16,19 @@ subtype 'Tree::Transform::XSLTish::Engine'
has 'rules_package' => (is => 'ro', isa => 'ClassName');
has 'context_stack' => (
- metaclass => 'Collection::Array',
+ traits => ['Array'],
is => 'rw',
isa => 'ArrayRef[Tree::Transform::XSLTish::Context]',
default => sub { [] },
- provides => {
- last => 'context',
- push => 'enter',
- pop => 'leave',
- empty => 'has_context',
+ handles => {
+ enter => 'push',
+ leave => 'pop',
+ has_context => 'count',
},
);
+sub context { return $_[0]->context_stack->[-1] }
+
has 'engine' => (
is => 'ro',
isa => 'Tree::Transform::XSLTish::Engine',
@@ -47,6 +45,7 @@ sub _build_engine {
return $factory->();
}
}
+ require Tree::XPathEngine;
return Tree::XPathEngine->new();
}
@@ -164,6 +163,8 @@ sub find_rule_by_name_in_package {
if (exists $rules->{$name}) {
return $rules->{$name};
}
+
+ return;
}
sub rule_matches {
@@ -296,7 +297,7 @@ L<find_rule_in_package> and returns the first defined result.
=head2 C<find_rule_in_package>
Gets all the rules having a C<match> attribute, filters those for
-which L<rule_matches> returns true, sorts them priority, and returns
+which L<rule_matches> returns true, sorts them by priority, and returns
the one with the highest priority.
Dies if there is more than one rule with the highest priority; returns