/[cvs]/nfo/perl/libs/XML/XSLT.pm
ViewVC logotype

Diff of /nfo/perl/libs/XML/XSLT.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Sat Apr 26 01:44:00 2003 UTC revision 1.2 by joko, Wed Apr 30 00:06:55 2003 UTC
# Line 6  Line 6 
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.2  2003/04/30 00:06:55  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  #    NEW: sub __evaluate_test__ now detects a variable name in an lvalue of an expression (e.g. $var=val, {$var}=val)
11  #  #
12  #    Revision 1.19  2002/02/18 09:05:14  gellyfish  #    Revision 1.19  2002/02/18 09:05:14  gellyfish
13  #    Refactoring  #    Refactoring
# Line 496  sub __get_stylesheet { Line 496  sub __get_stylesheet {
496    
497    foreach my $child ($xsl->getElementsByTagName ('*', 0))    foreach my $child ($xsl->getElementsByTagName ('*', 0))
498    {    {
499      my ($ns, $tag) = split(':', $child->getTagName());      my ($ns, $tag) = split(':', $child->getTagName());
500      if(not defined $tag)      if(not defined $tag)
501      {      {
502        $tag = $ns;        $tag = $ns;
# Line 2605  sub __evaluate_test__ { Line 2605  sub __evaluate_test__ {
2605        $self->debug("no test matches");        $self->debug("no test matches");
2606        return 0;        return 0;
2607      }      }
2608      
2609      # tests for variables|parameters
2610      } elsif ($test =~ /^\s*{*\$([\w\.\:\-]+)}*\s*(<=|>=|!=|=|<|>)\s*['"]?([^'"]*)['"]?\s*$/) {
2611        my $expval = $3;
2612        my $test   = $2;
2613    =pod
2614        my $nodeset=&_get_node_set($self,$1,$self->xml_document(),$path,$node,$variables);
2615        return ($expval ne '') unless @$nodeset;
2616        my $content = &__string__($self,$$nodeset[0]);
2617    =cut
2618        my $variable_name = $1;
2619        my $content = &__string__($self,$variables->{$variable_name});
2620        my $numeric = $content =~ /^\d+$/ && $expval =~ /^\d+$/ ? 1 : 0;
2621    
2622        $self->debug("evaluating $content $test $expval");
2623    
2624        if ( $test eq '!=' )
2625        {
2626           return $numeric ? $content != $expval : $content ne $expval;
2627        }
2628        elsif ( $test eq '=' )
2629        {
2630           return $numeric ? $content == $expval : $content eq $expval;
2631        }
2632        elsif ( $test eq '<' )
2633        {
2634           return $numeric ? $content < $expval : $content lt $expval;
2635        }
2636        elsif ( $test eq '>' )
2637        {
2638           return $numeric ? $content > $expval : $content gt $expval;
2639        }
2640        elsif ( $test eq '>=' )
2641        {
2642           return $numeric ? $content >= $expval : $content ge $expval;
2643        }
2644        elsif ( $test eq '<=' )
2645        {
2646           return $numeric ? $content <= $expval : $content le $expval;
2647        }
2648        else
2649        {
2650          $self->warn("no test matches while evaluating parameter comparison: $test");
2651          return 0;
2652        }
2653    } else {    } else {
2654      $self->debug("no match for test");      $self->debug("no match for test");
2655      return "";      return "";
2656    }    }
2657  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed