<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># $Id: Variable.pm,v 1.5 2001/03/16 11:10:08 matt Exp $

package XML::XPathEngine::Variable;
use strict;

# This class does NOT contain 1 instance of a variable
# see the XML::XPathEngine::Parser class for the instances
# This class simply holds the name of the var

sub new {
    my $class = shift;
    my ($pp, $name) = @_;
    bless { name =&gt; $name, path_parser =&gt; $pp }, $class;
}

sub as_string {
    my $self = shift;
    '\$' . $self-&gt;{name};
}

sub as_xml {
    my $self = shift;
    return "&lt;Variable&gt;" . $self-&gt;{name} . "&lt;/Variable&gt;\n";
}

sub get_value {
    my $self = shift;
    $self-&gt;{path_parser}-&gt;get_var($self-&gt;{name});
}

sub set_value {
    my $self = shift;
    my ($val) = @_;
    $self-&gt;{path_parser}-&gt;set_var($self-&gt;{name}, $val);
}

sub evaluate {
    my $self = shift;
    my $val = $self-&gt;get_value;
    return $val;
}

1;
</pre></body></html>