home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl5 / XML / XPath / Root.pm < prev    next >
Encoding:
Perl POD Document  |  2001-03-16  |  643 b   |  37 lines

  1. # $Id: Root.pm,v 1.6 2001/03/16 11:10:08 matt Exp $
  2.  
  3. package XML::XPath::Root;
  4. use strict;
  5. use XML::XPath::XMLParser;
  6. use XML::XPath::NodeSet;
  7.  
  8. sub new {
  9.     my $class = shift;
  10.     my $self; # actually don't need anything here - just a placeholder
  11.     bless \$self, $class;
  12. }
  13.  
  14. sub as_string {
  15.     # do nothing
  16. }
  17.  
  18. sub as_xml {
  19.     return "<Root/>\n";
  20. }
  21.  
  22. sub evaluate {
  23.     my $self = shift;
  24.     my $nodeset = shift;
  25.     
  26. #    warn "Eval ROOT\n";
  27.     
  28.     # must only ever occur on 1 node
  29.     die "Can't go to root on > 1 node!" unless $nodeset->size == 1;
  30.     
  31.     my $newset = XML::XPath::NodeSet->new();
  32.     $newset->push($nodeset->get_node(1)->getRootNode());
  33.     return $newset;
  34. }
  35.  
  36. 1;
  37.