| 1 |
=head1 NAME |
| 2 |
|
| 3 |
XML::LibXML::Attr - XML::LibXML Attribute Class |
| 4 |
|
| 5 |
=head1 SYNOPSIS |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
use XML::LibXML; |
| 10 |
# Only methods specific to Attribute nodes are listed here, |
| 11 |
# see the XML::LibXML::Node manpage for other methods |
| 12 |
|
| 13 |
$attr = XML::LibXML::Attr->new($name [,$value]); |
| 14 |
$string = $attr->getValue(); |
| 15 |
$string = $attr->value; |
| 16 |
$attr->setValue( $string ); |
| 17 |
$node = $attr->getOwnerElement(); |
| 18 |
$attr->setNamespace($nsURI, $prefix); |
| 19 |
$bool = $attr->isId; |
| 20 |
$string = $attr->serializeContent; |
| 21 |
|
| 22 |
=head1 DESCRIPTION |
| 23 |
|
| 24 |
This is the interface to handle Attributes like ordinary nodes. The naming of |
| 25 |
the class relies on the W3C DOM documentation. |
| 26 |
|
| 27 |
|
| 28 |
=head1 METHODS |
| 29 |
|
| 30 |
The class inherits from L<<<<<< XML::LibXML::Node >>>>>>. The documentation for Inherited methods is not listed here. |
| 31 |
|
| 32 |
Many functions listed here are extensively documented in the DOM Level 3 specification (L<<<<<< http://www.w3.org/TR/DOM-Level-3-Core/ >>>>>>). Please refer to the specification for extensive documentation. |
| 33 |
|
| 34 |
=over 4 |
| 35 |
|
| 36 |
=item new |
| 37 |
|
| 38 |
$attr = XML::LibXML::Attr->new($name [,$value]); |
| 39 |
|
| 40 |
Class constructor. If you need to work with ISO encoded strings, you should I<<<<<< always >>>>>> use the C<<<<<< createAttribute >>>>>> of L<<<<<< XML::LibXML::Document >>>>>>. |
| 41 |
|
| 42 |
|
| 43 |
=item getValue |
| 44 |
|
| 45 |
$string = $attr->getValue(); |
| 46 |
|
| 47 |
Returns the value stored for the attribute. If undef is returned, the attribute |
| 48 |
has no value, which is different of being C<<<<<< not specified >>>>>>. |
| 49 |
|
| 50 |
|
| 51 |
=item value |
| 52 |
|
| 53 |
$string = $attr->value; |
| 54 |
|
| 55 |
Alias for I<<<<<< getValue() >>>>>> |
| 56 |
|
| 57 |
|
| 58 |
=item setValue |
| 59 |
|
| 60 |
$attr->setValue( $string ); |
| 61 |
|
| 62 |
This is needed to set a new attribute value. If ISO encoded strings are passed |
| 63 |
as parameter, the node has to be bound to a document, otherwise the encoding |
| 64 |
might be done incorrectly. |
| 65 |
|
| 66 |
|
| 67 |
=item getOwnerElement |
| 68 |
|
| 69 |
$node = $attr->getOwnerElement(); |
| 70 |
|
| 71 |
returns the node the attribute belongs to. If the attribute is not bound to a |
| 72 |
node, undef will be returned. Overwriting the underlying implementation, the I<<<<<< parentNode >>>>>> function will return undef, instead of the owner element. |
| 73 |
|
| 74 |
|
| 75 |
=item setNamespace |
| 76 |
|
| 77 |
$attr->setNamespace($nsURI, $prefix); |
| 78 |
|
| 79 |
This function tries to bound the attribute to a given namespace. If C<<<<<< $nsURI >>>>>> is undefined or empty, the function discards any previous association of the |
| 80 |
attribute with a namespace. If the namespace was not previously declared in the |
| 81 |
context of the attribute, this function will fail. In this case you may wish to |
| 82 |
call setNamespace() on the ownerElement. If the namespace URI is non-empty and |
| 83 |
declared in the context of the attribute, but only with a different (non-empty) |
| 84 |
prefix, then the attribute is still bound to the namespace but gets a different |
| 85 |
prefix than C<<<<<< $prefix >>>>>>. The function also fails if the prefix is empty but the namespace URI is not |
| 86 |
(because unprefixed attributes should by definition belong to no namespace). |
| 87 |
This function returns 1 on success, 0 otherwise. |
| 88 |
|
| 89 |
|
| 90 |
=item isId |
| 91 |
|
| 92 |
$bool = $attr->isId; |
| 93 |
|
| 94 |
Determine whether an attribute is of type ID. For documents with a DTD, this |
| 95 |
information is only available if DTD loading/validation has been requested. For |
| 96 |
HTML documents parsed with the HTML parser ID detection is done automatically. |
| 97 |
In XML documents, all "xml:id" attributes are considered to be of type ID. |
| 98 |
|
| 99 |
|
| 100 |
=item serializeContent($docencoding) |
| 101 |
|
| 102 |
$string = $attr->serializeContent; |
| 103 |
|
| 104 |
This function is not part of DOM API. It returns attribute content in the form |
| 105 |
in which it serializes into XML, that is with all meta-characters properly |
| 106 |
quoted and with raw entity references (except for entities expanded during |
| 107 |
parse time). Setting the optional $docencoding flag to 1 enforces document |
| 108 |
encoding for the output string (which is then passed to Perl as a byte string). |
| 109 |
Otherwise the string is passed to Perl as (UTF-8 encoded) characters. |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
=back |
| 114 |
|
| 115 |
=head1 AUTHORS |
| 116 |
|
| 117 |
Matt Sergeant, |
| 118 |
Christian Glahn, |
| 119 |
Petr Pajas |
| 120 |
|
| 121 |
|
| 122 |
=head1 VERSION |
| 123 |
|
| 124 |
2.0134 |
| 125 |
|
| 126 |
=head1 COPYRIGHT |
| 127 |
|
| 128 |
2001-2007, AxKit.com Ltd. |
| 129 |
|
| 130 |
2002-2006, Christian Glahn. |
| 131 |
|
| 132 |
2006-2009, Petr Pajas. |
| 133 |
|
| 134 |
=cut |
| 135 |
|
| 136 |
|
| 137 |
=head1 LICENSE |
| 138 |
|
| 139 |
This program is free software; you can redistribute it and/or modify it under |
| 140 |
the same terms as Perl itself. |
| 141 |
|