| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | XML::Easy::Element - abstract form of XML element | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | use XML::Easy::Element; | ||||||||||
| 8 | |||||||||||
| 9 | $element = XML::Easy::Element->new("a", { href => "#there" }, | ||||||||||
| 10 | $content); | ||||||||||
| 11 | |||||||||||
| 12 | $type_name = $element->type_name; | ||||||||||
| 13 | $attributes = $element->attributes; | ||||||||||
| 14 | $href = $element->attribute("href"); | ||||||||||
| 15 | $content = $element->content_object; | ||||||||||
| 16 | |||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||
| 18 | |||||||||||
| 19 | An object of this class represents an XML element, a node in the tree | ||||||||||
| 20 | making up an XML document. This is in an abstract form, intended | ||||||||||
| 21 | for general manipulation. It is completely isolated from the textual | ||||||||||
| 22 | representation of XML, and holds only the meaningful content of the | ||||||||||
| 23 | element. The data in an element object cannot be modified: different | ||||||||||
| 24 | data requires the creation of a new object. | ||||||||||
| 25 | |||||||||||
| 26 | The properties of an XML element are of three kinds. Firstly, the element | ||||||||||
| 27 | has exactly one type, which is referred to by a name. Secondly, the | ||||||||||
| 28 | element has a set of zero or more attributes. Each attribute consists of | ||||||||||
| 29 | a name, which is unique among the attributes of the element, and a value, | ||||||||||
| 30 | which is a string of characters. Finally, the element has content, which | ||||||||||
| 31 | is a sequence of zero or more characters and (recursively) elements, | ||||||||||
| 32 | interspersed in any fashion. | ||||||||||
| 33 | |||||||||||
| 34 | The element type name and attribute names all follow the XML syntax | ||||||||||
| 35 | for names. This allows the use of a wide set of Unicode characters, | ||||||||||
| 36 | with some restrictions. Attribute values and character content can use | ||||||||||
| 37 | almost all Unicode characters, with only a few characters (such as most | ||||||||||
| 38 | of the ASCII control characters) prohibited by the specification from | ||||||||||
| 39 | being directly represented in XML. | ||||||||||
| 40 | |||||||||||
| 41 | This class is not meant to be subclassed. XML elements are unextendable, | ||||||||||
| 42 | dumb data. Element objects are better processed using the functions in | ||||||||||
| 43 | L<XML::Easy::NodeBasics> than using the methods of this class. | ||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | |||||||||||
| 47 | package XML::Easy::Element; | ||||||||||
| 48 | |||||||||||
| 49 | 15 | ▶ | { use 5.008; } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 50 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 51 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 52 | |||||||||||
| 53 | 15 | ▶ | use XML::Easy::Content 0.007 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 54 | |||||||||||
| 55 | 15 | our $VERSION = "0.011"; | |||||||||
| 56 | |||||||||||
| 57 | 15 | eval { local $SIG{__DIE__}; | |||||||||
| 58 | 15 | require XSLoader; | |||||||||
| 59 | 15 | ▶ | XSLoader::load("XML::Easy", $VERSION) unless defined &new; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | }; | ||||||||||
| 61 | |||||||||||
| 62 | 15 | ▶ | if($@ eq "") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | close(DATA); | |||||||||
| 64 | } else { | ||||||||||
| 65 | 15 | (my $filename = __FILE__) =~ tr# -~##cd; | |||||||||
| 66 | 15 | local $/ = undef; | |||||||||
| 67 | 15 | my $pp_code = "#line 83 \"$filename\"\n".<DATA>; | |||||||||
| 68 | 15 | close(DATA); | |||||||||
| 69 | { | ||||||||||
| 70 | 15 | local $SIG{__DIE__}; | |||||||||
| 71 | 15 | eval $pp_code; | |||||||||
| 72 | } | ||||||||||
| 73 | 15 | ▶ | die $@ if $@ ne ""; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 15 | *content = \&content_twine; | |||||||||
| 77 | |||||||||||
| 78 | 15 | 1; | |||||||||
| 79 | |||||||||||
| 80 | __DATA__ | ||||||||||