File Coverage

blib/lib/XML/Easy/Text.pm
Criterion Covered Total %
statement 250 251 99.6
branch 121 126 96.0
condition 13 27 48.1
subroutine 47 47 100.0
pod 10 10 100.0
total 441 461 95.6


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             XML::Easy::Text - XML parsing and serialisation
4              
5             =head1 SYNOPSIS
6              
7             use XML::Easy::Text qw(
8             xml10_read_content_object xml10_read_element
9             xml10_read_document xml10_read_extparsedent_object);
10              
11             $content = xml10_read_content_object($text);
12             $element = xml10_read_element($text);
13             $element = xml10_read_document($text);
14             $content = xml10_read_extparsedent_object($text);
15              
16             use XML::Easy::Text qw(
17             xml10_write_content xml10_write_element
18             xml10_write_document xml10_write_extparsedent);
19              
20             $text = xml10_write_content($content);
21             $text = xml10_write_element($element);
22             $text = xml10_write_document($element, "UTF-8");
23             $text = xml10_write_extparsedent($content, "UTF-8");
24              
25             =head1 DESCRIPTION
26              
27             This module supplies functions that parse and serialise XML data
28             according to the XML 1.0 specification.
29              
30             This module is oriented towards the use of XML to represent data
31             for interchange purposes, rather than the use of XML as markup of
32             principally textual data. It does not perform any schema processing,
33             and does not interpret DTDs or any other kind of schema. It adheres
34             strictly to the XML specification, in all its awkward details, except
35             for the aforementioned DTDs.
36              
37             XML data in memory is represented using a tree of
38             L and L
39             objects. Such a tree encapsulates all the structure and data content
40             of an XML element or document, without any irrelevant detail resulting
41             from the textual syntax.
42             These node trees are readily manipulated by the functions
43             in L.
44              
45             The functions of this module are implemented
46             in C for performance, with a pure Perl backup version (which has good
47             performance compared to other pure Perl parsers) for systems that can't
48             handle XS modules.
49              
50             =cut
51              
52             package XML::Easy::Text;
53              
54 7     7   111336 { use 5.008; }
  7         26  
55 7     7   36 use warnings;
  7         16  
  7         216  
56 7     7   37 use strict;
  7         16  
  7         191  
57              
58 7     7   1050 use XML::Easy::Content 0.007 ();
  7         123  
  7         180  
59 7     7   1041 use XML::Easy::Element 0.007 ();
  7         137  
  7         356  
60              
61             our $VERSION = "0.011";
62              
63 7     7   52 use parent "Exporter";
  7         17  
  7         43  
64             our @EXPORT_OK = qw(
65             xml10_read_content_object xml10_read_content_twine
66             xml10_read_content
67             xml10_read_element
68             xml10_read_document
69             xml10_read_extparsedent_object xml10_read_extparsedent_twine
70             xml10_read_extparsedent
71             xml10_write_content xml10_write_element
72             xml10_write_document xml10_write_extparsedent
73             );
74              
75             eval { local $SIG{__DIE__};
76             require XSLoader;
77             XSLoader::load("XML::Easy", $VERSION)
78             unless defined &xml10_write_document;
79             };
80              
81             if($@ eq "") {
82             close(DATA);
83             } else {
84             (my $filename = __FILE__) =~ tr# -~##cd;
85             local $/ = undef;
86             my $pp_code = "#line 98 \"$filename\"\n".;
87             close(DATA);
88             {
89             local $SIG{__DIE__};
90             eval $pp_code;
91             }
92             die $@ if $@ ne "";
93             }
94              
95             *xml10_read_content = \&xml10_read_content_twine;
96             *xml10_read_extparsedent = \&xml10_read_extparsedent_twine;
97              
98             1;
99 3     3   16  
  3         43  
  3         159  
100 3         532 __DATA__