Last change
on this file since 24626 was 24626, checked in by jmt12, 13 years ago |
An (almost) complete copy of the perllib directory from a (circa SEP2011) head checkout from Greenstone 2 trunk - in order to try and make merging in this extension a little easier later on (as there have been some major changes to buildcol.pl commited in the main trunk but not in the x64 branch)
|
File size:
1.7 KB
|
Line | |
---|
1 | # $Id: Namespace.pm 7909 2004-08-06 05:11:55Z mdewsnip $
|
---|
2 |
|
---|
3 | package XML::XPath::Node::Namespace;
|
---|
4 |
|
---|
5 | use strict;
|
---|
6 | use vars qw/@ISA/;
|
---|
7 |
|
---|
8 | @ISA = ('XML::XPath::Node');
|
---|
9 |
|
---|
10 | package XML::XPath::Node::NamespaceImpl;
|
---|
11 |
|
---|
12 | use vars qw/@ISA/;
|
---|
13 | @ISA = ('XML::XPath::NodeImpl', 'XML::XPath::Node::Namespace');
|
---|
14 | use XML::XPath::Node ':node_keys';
|
---|
15 |
|
---|
16 | sub new {
|
---|
17 | my $class = shift;
|
---|
18 | my ($prefix, $expanded) = @_;
|
---|
19 |
|
---|
20 | my $pos = XML::XPath::Node->nextPos;
|
---|
21 |
|
---|
22 | my @vals;
|
---|
23 | @vals[node_global_pos, node_prefix, node_expanded] =
|
---|
24 | ($pos, $prefix, $expanded);
|
---|
25 | my $self = \@vals;
|
---|
26 |
|
---|
27 | bless $self, $class;
|
---|
28 | }
|
---|
29 |
|
---|
30 | sub getNodeType { NAMESPACE_NODE }
|
---|
31 |
|
---|
32 | sub isNamespaceNode { 1; }
|
---|
33 |
|
---|
34 | sub getPrefix {
|
---|
35 | my $self = shift;
|
---|
36 | $self->[node_prefix];
|
---|
37 | }
|
---|
38 |
|
---|
39 | sub getExpanded {
|
---|
40 | my $self = shift;
|
---|
41 | $self->[node_expanded];
|
---|
42 | }
|
---|
43 |
|
---|
44 | sub getValue {
|
---|
45 | my $self = shift;
|
---|
46 | $self->[node_expanded];
|
---|
47 | }
|
---|
48 |
|
---|
49 | sub getData {
|
---|
50 | my $self = shift;
|
---|
51 | $self->[node_expanded];
|
---|
52 | }
|
---|
53 |
|
---|
54 | sub string_value {
|
---|
55 | my $self = shift;
|
---|
56 | $self->[node_expanded];
|
---|
57 | }
|
---|
58 |
|
---|
59 | sub toString {
|
---|
60 | my $self = shift;
|
---|
61 | my $string = '';
|
---|
62 | return '' unless defined $self->[node_expanded];
|
---|
63 | if ($self->[node_prefix] eq '#default') {
|
---|
64 | $string .= ' xmlns="';
|
---|
65 | }
|
---|
66 | else {
|
---|
67 | $string .= ' xmlns:' . $self->[node_prefix] . '="';
|
---|
68 | }
|
---|
69 | $string .= XML::XPath::Node::XMLescape($self->[node_expanded], '"&<');
|
---|
70 | $string .= '"';
|
---|
71 | }
|
---|
72 |
|
---|
73 | 1;
|
---|
74 | __END__
|
---|
75 |
|
---|
76 | =head1 NAME
|
---|
77 |
|
---|
78 | Namespace - an XML namespace node
|
---|
79 |
|
---|
80 | =head1 API
|
---|
81 |
|
---|
82 | =head2 new ( prefix, expanded )
|
---|
83 |
|
---|
84 | Create a new namespace node, expanded is the expanded namespace URI.
|
---|
85 |
|
---|
86 | =head2 getPrefix
|
---|
87 |
|
---|
88 | Returns the prefix
|
---|
89 |
|
---|
90 | =head2 getExpanded
|
---|
91 |
|
---|
92 | Returns the expanded URI
|
---|
93 |
|
---|
94 | =head2 toString
|
---|
95 |
|
---|
96 | Returns a string that you can add to the list
|
---|
97 | of attributes of an element: xmlns:prefix="expanded"
|
---|
98 |
|
---|
99 | =cut
|
---|
Note:
See
TracBrowser
for help on using the repository browser.