File Coverage

blib/lib/XML/Easy/Text.pm
Criterion Covered Total %
statement 232 233 99.5
branch 121 126 96.0
condition 7 9 77.7
subroutine 41 41 100.0
pod 10 10 100.0
total 411 419 98.0


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