| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
XML::Easy - XML processing with a clean interface |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use XML::Easy::NodeBasics qw(xml_element xml_e_attribute); |
|
8
|
|
|
|
|
|
|
use XML::Easy::Text qw(xml10_read_document xml10_write_document); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$element = xml_element("a", { href => "there" }, "there"); |
|
11
|
|
|
|
|
|
|
$element = xml10_read_document('there'); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$href = xml_e_attribute($element, "href"); |
|
14
|
|
|
|
|
|
|
$text = xml10_write_document($element); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# see specific modules for many more functions |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
L is a collection of modules relating to the processing, |
|
21
|
|
|
|
|
|
|
parsing, and serialisation of XML data. It is oriented towards the |
|
22
|
|
|
|
|
|
|
use of XML to represent data for interchange purposes, rather than the |
|
23
|
|
|
|
|
|
|
use of XML as markup of principally textual data. It does not perform |
|
24
|
|
|
|
|
|
|
any schema processing, and does not interpret DTDs or any other kind |
|
25
|
|
|
|
|
|
|
of schema. It adheres strictly to the XML specification, in all its |
|
26
|
|
|
|
|
|
|
awkward details, except for the aforementioned DTDs. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
L strictly separates the in-program manipulation of XML |
|
29
|
|
|
|
|
|
|
data from the processing of the textual form of XML. This shields |
|
30
|
|
|
|
|
|
|
the XML user from the inconvenient and obscure aspects of XML syntax. |
|
31
|
|
|
|
|
|
|
XML data nodes are mainly processed in a clean functional style, using |
|
32
|
|
|
|
|
|
|
the L module. In the (very likely) event that |
|
33
|
|
|
|
|
|
|
an application requires some more purpose-specific XML data processing |
|
34
|
|
|
|
|
|
|
facilities, they are readily built on top of L, |
|
35
|
|
|
|
|
|
|
retaining the abstraction from textual XML. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
When XML must be handled in textual form, for input and output, |
|
38
|
|
|
|
|
|
|
the L module supplies a parser and a serialiser. |
|
39
|
|
|
|
|
|
|
The interfaces here, too, are functional in nature. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
There are other modules for some ancillary aspects of XML processing. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 MODULES |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The modules in the L distribution are: |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item L |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This document. For historical reasons, this can also be loaded as |
|
52
|
|
|
|
|
|
|
a module, and (though it is deprecated) some of the functions from |
|
53
|
|
|
|
|
|
|
L can be imported from here. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item L |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This module provides various type-testing functions, relating to data |
|
58
|
|
|
|
|
|
|
types used in the L ensemble. These are mainly intended to be |
|
59
|
|
|
|
|
|
|
used to enforce validity of data being processed by XML-related functions. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item L |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item L |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
These are classes used to represent XML data for general manipulation. |
|
66
|
|
|
|
|
|
|
Objects of these classes hold the meaningful content of the data, |
|
67
|
|
|
|
|
|
|
independent of textual representation. The data in these nodes cannot |
|
68
|
|
|
|
|
|
|
be modified: different data requires new nodes. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item L |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This module supplies functions concerned with the creation, examination, |
|
73
|
|
|
|
|
|
|
and other manipulation of XML data nodes (content chunks and elements). |
|
74
|
|
|
|
|
|
|
The nodes are dumb data objects, best manipulated using plain functions |
|
75
|
|
|
|
|
|
|
such as the ones in this module. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item L |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This module supplies Perl regular expressions describing the grammar of |
|
80
|
|
|
|
|
|
|
XML 1.0. This is intended to support doing irregular things with XML, |
|
81
|
|
|
|
|
|
|
rather than for normal parsing. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item L |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This module supplies functions that parse and serialise XML data as text |
|
86
|
|
|
|
|
|
|
according to the XML 1.0 specification. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 OTHER DISTRIBUTIONS |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Other CPAN distributions that work with L are: |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item L |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
A testing tool, providing L-style functions that check |
|
99
|
|
|
|
|
|
|
whether XML nodes are as expected. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item L |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Provides a way to construct XML data nodes by procedural code. |
|
104
|
|
|
|
|
|
|
Some programmers will find this more comfortable than the functional |
|
105
|
|
|
|
|
|
|
style offered by L. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item L |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Helps to parse things that are encoded in XML in common ways. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item C |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This namespace exists to contain modules that perform transformations |
|
114
|
|
|
|
|
|
|
on XML documents, or parts thereof, in the form of L |
|
115
|
|
|
|
|
|
|
and L nodes. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
package XML::Easy; |
|
122
|
|
|
|
|
|
|
|
|
123
|
3
|
|
|
3
|
|
127224
|
{ use 5.008; } |
|
|
3
|
|
|
|
|
13
|
|
|
124
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
115
|
|
|
125
|
3
|
|
|
3
|
|
16
|
use strict; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
117
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
our $VERSION = "0.011"; |
|
128
|
|
|
|
|
|
|
|
|
129
|
3
|
|
|
3
|
|
1315
|
use parent "Exporter"; |
|
|
3
|
|
|
|
|
770
|
|
|
|
3
|
|
|
|
|
18
|
|
|
130
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
131
|
|
|
|
|
|
|
xml10_read_content xml10_read_element |
|
132
|
|
|
|
|
|
|
xml10_read_document xml10_read_extparsedent |
|
133
|
|
|
|
|
|
|
xml10_write_content xml10_write_element |
|
134
|
|
|
|
|
|
|
xml10_write_document xml10_write_extparsedent |
|
135
|
|
|
|
|
|
|
); |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
require XML::Easy::Text; |
|
138
|
|
|
|
|
|
|
XML::Easy::Text->VERSION($VERSION); |
|
139
|
|
|
|
|
|
|
XML::Easy::Text->import(@EXPORT_OK); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L, |
|
144
|
|
|
|
|
|
|
L, |
|
145
|
|
|
|
|
|
|
L, |
|
146
|
|
|
|
|
|
|
L, |
|
147
|
|
|
|
|
|
|
L |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Andrew Main (Zefram) |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Copyright (C) 2008, 2009 PhotoBox Ltd |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (C) 2009, 2010, 2011, 2017 |
|
158
|
|
|
|
|
|
|
Andrew Main (Zefram) |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 LICENSE |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
163
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; |