Difference between revisions of "API:EPrints/XML"
Line 14: | Line 14: | ||
For preference, use the methods in [[API:EPrints/Handle/XML|EPrints::Handle::XML]] | For preference, use the methods in [[API:EPrints/Handle/XML|EPrints::Handle::XML]] | ||
+ | |||
Line 48: | Line 49: | ||
$xml->dispose( $dom_node ); | $xml->dispose( $dom_node ); | ||
− | + | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | |
+ | <span style='display:none'>User Comments</span> | ||
+ | <!-- Edit below this comment --> | ||
+ | |||
+ | <!-- Pod2Wiki= --> | ||
+ | </div> | ||
+ | <!-- Pod2Wiki=head_description --> | ||
+ | ==DESCRIPTION== | ||
EPrints can use either XML::DOM, XML::LibXML or XML::GDOME modules to generate and process XML. Some of the functionality of these modules differs so this module abstracts such functionality so that all the module specific code is in one place. | EPrints can use either XML::DOM, XML::LibXML or XML::GDOME modules to generate and process XML. Some of the functionality of these modules differs so this module abstracts such functionality so that all the module specific code is in one place. | ||
Line 233: | Line 241: | ||
$node = $xml->clone_node( $node ) | $node = $xml->clone_node( $node ) | ||
Returns a clone of $node only (no children). The new node will be owned by this object. | Returns a clone of $node only (no children). The new node will be owned by this object. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
Line 290: | Line 285: | ||
Options: | Options: | ||
indent - if true will indent the XML tree | indent - if true will indent the XML tree | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
Line 322: | Line 298: | ||
$xml->dispose( $node ) | $xml->dispose( $node ) | ||
Dispose and free the memory used by $node. | Dispose and free the memory used by $node. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> |
Revision as of 17:27, 31 December 2010
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
NAME
EPrints::XML - XML Abstraction Module
SYNOPSIS
my $xml = $repository->xml; $doc = $xml->parse_string( $string ); $doc = $xml->parse_file( $filename ); $doc = $xml->parse_url( $url ); $utf8_string = $xml->to_string( $dom_node, %opts ); $dom_node = $xml->clone( $dom_node ); # deep $dom_node = $xml->clone_node( $dom_node ); # shallow # clone and return child nodes $dom_node = $xml->contents_of( $dom_node ); # Return text child nodes as a string $utf8_string = $xml->text_contents_of( $dom_node ); $dom_node = $xml->create_element( $name, %attr ); $dom_node = $xml->create_text_node( $value ); $dom_node = $xml->create_comment( $value ); $dom_node = $xml->create_document_fragment; $xml->dispose( $dom_node );
DESCRIPTION
EPrints can use either XML::DOM, XML::LibXML or XML::GDOME modules to generate and process XML. Some of the functionality of these modules differs so this module abstracts such functionality so that all the module specific code is in one place.
METHODS
Parsing
parse_string
$doc = $xml->parse_string( $string, %opts )
Returns an XML document parsed from $string.
parse_file
$doc = $xml->parse_file( $filename, %opts )
Returns an XML document parsed from the file called $filename.
base_path - base path to load DTD files from no_expand - don't expand entities
parse_url
$doc = $xml->parse_url( $url, %opts )
Returns an XML document parsed from the content located at $url.
Node Creation
create_element
$node = $xml->create_element( $name [, @attrs ] )
Returns a new XML element named $name with optional attribute pairs @attrs.
create_cdata_section
$node = $xml->create_cdata_section( $value )
Returns a CDATA section containing $value.
create_text_node
$node = $xml->create_text_node( $value )
Returns a new XML text node containing $value.
create_comment
$node = $xml->create_comment( $value )
Returns a new XML comment containing $value.
create_document_fragment
$node = $xml->create_document_fragment
Returns a new XML document fragment.
Other
is
$bool = $xml->is( $node, $type [, $type ... ] )
Returns true if $node is one of the given node types: Document, DocumentFragment, Element, Comment, Text.
clone
$node = $xml->clone( $node )
Returns a deep clone of $node. The new node(s) will be owned by this object.
clone_node
$node = $xml->clone_node( $node )
Returns a clone of $node only (no children). The new node will be owned by this object.
contents_of
$node = $xml->contents_of( $node )
Returns a document fragment containing a copy of all the children of $node.
text_contents_of
$string = $xml->text_contents_of( $node )
Returns the concantenated value of all text nodes in $node (or the value of $node if $node is a text node).
to_string
$utf8_string = $xml->to_string( $node, %opts )
Serialises and returns the $node as a UTF-8 string.
To generate an XHTML string see EPrints::XHTML.
Options: indent - if true will indent the XML tree
dispose
$xml->dispose( $node )
Dispose and free the memory used by $node.