File: XPath.pm

package info (click to toggle)
latexml 0.8.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,920 kB
  • sloc: xml: 109,048; perl: 30,224; sh: 179; javascript: 28; makefile: 13
file content (43 lines) | stat: -rw-r--r-- 1,699 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# /=====================================================================\ #
# |  LaTeXML::Common::XML::XPath                                        | #
# | XML Parser (wrapper for XML::LibXML                                 | #
# |=====================================================================| #
# | Part of LaTeXML:                                                    | #
# |  Public domain software, produced as part of work done by the       | #
# |  United States Government & not subject to copyright in the US.     | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov>                        #_#     | #
# | http://dlmf.nist.gov/LaTeXML/                              (o o)    | #
# \=========================================================ooo==U==ooo=/ #
package LaTeXML::Common::XML::XPath;
use strict;
use warnings;
use XML::LibXML::XPathContext;

sub new {
  my ($class, %mappings) = @_;
  my $context = XML::LibXML::XPathContext->new();
  foreach my $prefix (keys %mappings) {
    $context->registerNs($prefix => $mappings{$prefix}); }
  return bless { context => $context }, $class; }

sub registerNS {
  my ($self, $prefix, $url) = @_;
  $$self{context}->registerNs($prefix => $url);
  return; }

sub registerFunction {
  my ($self, $name, $function) = @_;
  $$self{context}->registerFunction($name => $function);
  return; }

sub findnodes {
  my ($self, $xpath, $node) = @_;
  return $$self{context}->findnodes($xpath, $node); }

sub findvalue {
  my ($self, $xpath, $node) = @_;
  return $$self{context}->findvalue($xpath, $node); }

#======================================================================
1;