Difference between revisions of "API:EPrints/XML"

From EPrints Documentation
Jump to: navigation, search
(New page: <!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost. -...)
 
(Removing all content from page)
Line 1: Line 1:
<!-- Pod2Wiki=_preamble_
 
This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost.
 
-->{{Pod2Wiki}}{{API:Source|file=EPrints/XML.pm|package_name=EPrints::XML}}[[Category:API|XML]]<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_name -->=NAME=
 
'''EPrints::XML''' - XML Abstraction Module
 
  
<!-- End of Pod2Wiki -->
 
<!-- 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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_parse_xml_string -->==parse_xml_string==
 
 
  $doc = EPrints::XML::parse_xml_string( $string );
 
 
Return a DOM document describing the XML string %string.
 
 
If we are using GDOME then it will create an XML::GDOME document instead.
 
 
In the event of an error in the XML file, report to STDERR and return undef.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_parse_xml -->==parse_xml==
 
 
  $doc = EPrints::XML::parse_xml( $file, $basepath, $no_expand )
 
 
Return a DOM document describing the XML file specified by $file. With the optional root path for looking for the DTD of $basepath. If $noexpand is true then entities will not be expanded.
 
 
If we are using GDOME then it will create an XML::GDOME document instead.
 
 
In the event of an error in the XML file, report to STDERR and return undef.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_event_parse -->==event_parse==
 
 
  event_parse( $fh, $handler )
 
 
Parses the XML from filehandle $fh, calling the appropriate events in the handler where necessary.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_dom -->==is_dom==
 
 
  $boolean = is_dom( $node, @nodestrings )
 
 
return true if node is an object of type XML::DOM/GDOME::$nodestring
 
where $nodestring is any value in @nodestrings.
 
 
 
if $nodestring is not defined then return true if $node is any
 
XML::DOM/GDOME object.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_dispose -->==dispose==
 
 
  EPrints::XML::dispose( $node )
 
 
Dispose of this node if needed. Only XML::DOM nodes need to be disposed as they have cyclic references. XML::GDOME nodes are C structs.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_clone_node -->==clone_node==
 
 
  $newnode = EPrints::XML::clone_node( $node, $deep )
 
 
Clone the given DOM node and return the new node. Always does a deep copy.
 
 
This function does different things for XML::DOM &amp; XML::GDOME but the result should be the same.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_clone_and_own -->==clone_and_own==
 
 
  $newnode = EPrints::XML::clone_and_own( $doc, $node, $deep )
 
 
This function abstracts the different ways that XML::DOM and  XML::GDOME allow objects to be moved between documents.
 
 
It returns a clone of $node but belonging to the document $doc no matter what document $node belongs to.
 
 
If $deep is true then the clone will also clone all nodes belonging to $node, recursively.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_to_string -->==to_string==
 
 
  $string = EPrints::XML::to_string( $node, [$enc], [$noxmlns] )
 
 
Return the given node (and its children) as a UTF8 encoded string.
 
 
$enc is only used when $node is a document.
 
 
If $stripxmlns is true then all xmlns attributes and namespace prefixes are removed. Handy for making legal XHTML.
 
 
Papers over some cracks, specifically that XML::GDOME does not  support toString on a DocumentFragment, and that XML::GDOME does not insert a space before the / in tags with no children, which confuses some browsers. Eg. &lt;br/&gt; vs &lt;br /&gt;
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_make_document -->==make_document==
 
 
  $document = EPrints::XML::make_document()
 
 
Create and return an empty document.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_write_xml_file -->==write_xml_file==
 
 
  EPrints::XML::write_xml_file( $node, $filename )
 
 
Write the given XML node $node to file $filename.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_write_xhtml_file -->==write_xhtml_file==
 
 
  EPrints::XML::write_xhtml_file( $node, $filename )
 
 
Write the given XML node $node to file $filename with an XHTML doctype.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_tidy -->==tidy==
 
 
  EPrints::XML::tidy( $domtree, { collapse=&gt;['element','element'...] }, [$indent] )
 
 
Neatly indent the DOM tree.
 
 
Note that this should not be done to XHTML as the differenct between white space and no white space does matter sometimes.
 
 
This method modifies the tree it is given. Possibly there should be a version which returns a new version without modifying the tree.
 
 
Indent is the number of levels to ident by.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_namespace -->==namespace==
 
 
  $namespace = EPrints::XML::namespace( $thing, $version )
 
 
Return the namespace for the given version of the eprints xml.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
 
{{API:Undocumented Methods}}<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_contents_of -->==contents_of==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_debug_xml -->==debug_xml==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_document_to_string -->==document_to_string==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_empty -->==is_empty==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_make_document_fragment -->==make_document_fragment==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_parse_url -->==parse_url==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_trim_whitespace -->==trim_whitespace==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
 

Revision as of 15:41, 12 August 2009