6 |
# and Egon Willighagen, egonw@sci.kun.nl |
# and Egon Willighagen, egonw@sci.kun.nl |
7 |
# |
# |
8 |
# $Log$ |
# $Log$ |
9 |
# Revision 1.1 2003/04/26 01:44:00 joko |
# Revision 1.3 2003/05/01 20:10:36 joko |
10 |
# initial commit - from http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/xmlxslt/XML-XSLT/lib/XML/XSLT.pm?rev=1.19&content-type=text/vnd.viewcvs-markup |
# increased version number to 0.41 |
11 |
|
# |
12 |
|
# Revision x.xx 2003/04/30 00:06:55 joko |
13 |
|
# * sub __evaluate_test__ now detects a variable name in |
14 |
|
# an lvalue of an expression (e.g. $var=val, {$var}=val) |
15 |
# |
# |
16 |
# Revision 1.19 2002/02/18 09:05:14 gellyfish |
# Revision 1.19 2002/02/18 09:05:14 gellyfish |
17 |
# Refactoring |
# Refactoring |
86 |
|
|
87 |
use vars qw ( $VERSION @ISA @EXPORT_OK $AUTOLOAD ); |
use vars qw ( $VERSION @ISA @EXPORT_OK $AUTOLOAD ); |
88 |
|
|
89 |
$VERSION = '0.40'; |
$VERSION = '0.41'; |
90 |
|
|
91 |
@ISA = qw( Exporter ); |
@ISA = qw( Exporter ); |
92 |
@EXPORT_OK = qw( &transform &serve ); |
@EXPORT_OK = qw( &transform &serve ); |
500 |
|
|
501 |
foreach my $child ($xsl->getElementsByTagName ('*', 0)) |
foreach my $child ($xsl->getElementsByTagName ('*', 0)) |
502 |
{ |
{ |
503 |
my ($ns, $tag) = split(':', $child->getTagName()); |
my ($ns, $tag) = split(':', $child->getTagName()); |
504 |
if(not defined $tag) |
if(not defined $tag) |
505 |
{ |
{ |
506 |
$tag = $ns; |
$tag = $ns; |
2609 |
$self->debug("no test matches"); |
$self->debug("no test matches"); |
2610 |
return 0; |
return 0; |
2611 |
} |
} |
2612 |
|
|
2613 |
|
# tests for variables|parameters |
2614 |
|
} elsif ($test =~ /^\s*{*\$([\w\.\:\-]+)}*\s*(<=|>=|!=|=|<|>)\s*['"]?([^'"]*)['"]?\s*$/) { |
2615 |
|
my $expval = $3; |
2616 |
|
my $test = $2; |
2617 |
|
=pod |
2618 |
|
my $nodeset=&_get_node_set($self,$1,$self->xml_document(),$path,$node,$variables); |
2619 |
|
return ($expval ne '') unless @$nodeset; |
2620 |
|
my $content = &__string__($self,$$nodeset[0]); |
2621 |
|
=cut |
2622 |
|
my $variable_name = $1; |
2623 |
|
my $content = &__string__($self,$variables->{$variable_name}); |
2624 |
|
my $numeric = $content =~ /^\d+$/ && $expval =~ /^\d+$/ ? 1 : 0; |
2625 |
|
|
2626 |
|
$self->debug("evaluating $content $test $expval"); |
2627 |
|
|
2628 |
|
if ( $test eq '!=' ) |
2629 |
|
{ |
2630 |
|
return $numeric ? $content != $expval : $content ne $expval; |
2631 |
|
} |
2632 |
|
elsif ( $test eq '=' ) |
2633 |
|
{ |
2634 |
|
return $numeric ? $content == $expval : $content eq $expval; |
2635 |
|
} |
2636 |
|
elsif ( $test eq '<' ) |
2637 |
|
{ |
2638 |
|
return $numeric ? $content < $expval : $content lt $expval; |
2639 |
|
} |
2640 |
|
elsif ( $test eq '>' ) |
2641 |
|
{ |
2642 |
|
return $numeric ? $content > $expval : $content gt $expval; |
2643 |
|
} |
2644 |
|
elsif ( $test eq '>=' ) |
2645 |
|
{ |
2646 |
|
return $numeric ? $content >= $expval : $content ge $expval; |
2647 |
|
} |
2648 |
|
elsif ( $test eq '<=' ) |
2649 |
|
{ |
2650 |
|
return $numeric ? $content <= $expval : $content le $expval; |
2651 |
|
} |
2652 |
|
else |
2653 |
|
{ |
2654 |
|
$self->warn("no test matches while evaluating parameter comparison: $test"); |
2655 |
|
return 0; |
2656 |
|
} |
2657 |
} else { |
} else { |
2658 |
$self->debug("no match for test"); |
$self->debug("no match for test"); |
2659 |
return ""; |
return ""; |
2660 |
} |
} |
2661 |
} |
} |