logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

XML::XUpdate::LibXML - Simple implementation of XUpdate format

Author

       Petr Pajas, pajas@matfyz.cz

Description

       This module implements the XUpdate format described in XUpdate Working Draft from 2000-09-14
       (http://www.xmldb.org/xupdate/xupdate-wd.html).  The implementation is based on XML::LibXML DOM API.

   "new"
           my $xupdate = XML::XUpdate::LibXML->new();

       Creates a new XUpdate object. You may use this object to update several different DOM trees using several
       different XUpdate descriptions. The advantage of it is that an xupdate object remembers values all
       variables declared in XUpdate documents.

   "$xupdate->registerNs($prefix,$uri)"
       Tell the XPath engine to resolve given namespace prefix as the given namespace URI. This is particularly
       useful to bind a default namespace to a prefix because XPath doesn't honour default namespaces.

   "$xupdate->process($document_dom,$xupdate_dom)"
       This function takes two DOM trees as its arguments. It works by updating the first tree according to all
       XUpdate commands included in the second one. All XUpdate commands must be children of the root element of
       the second tree and must all belong to XUpdate namespace "http://www.xmldb.org/xupdate". The namespace
       URI may be changed with set_namespace method.

   "$xupdate->set_namespace($URI)"
       You may use this method to change the namespace of XUpdate elements.  The default namespace is
       "http://www.xmldb.org/xupdate".

   "$xupdate->namespace()"
       Returns XUpdate namespace URI used by XUpdate processor to identify XUpdate commands.

   EXPORT
       None.

Differences Between 0.2.X And 0.3.X

       In 0.3.x different implementation of XUpdate variables is used. Now variables contain the actual objects
       resulting from an XPath query, and not their textual content as in versions 0.2.x of
       XML::XUpdate::LibXML.

       Also, value-of instruction results in copies of the actual objects it selects rather than their textual
       content as in 0.2.x.

       I hope the new implementation is more conformant with the (not very clear) XUpdate Working Draft and
       therefore more compatible with other XUpdate implementations.

Differences Between 0.3.X And 0.4.X

       Commands are applied to all nodes of the select nodeset, not just the first one.

Differences Between 0.4.X And 0.5.X

       XML::LibXML::XPathContext is used for variable code providing more flexible and powerfull implementation.
       New and hopefully correct implementation of the problematic child attribute of update command has been
       introduced.

       Support for registrering namespace prefix with the XPath engine (allows binding document's default
       namespace to a prefix).

       Several bug fixes.

Differences Between 0.5.X And 0.6.X

       xu:if command implementation contributed by Amir Guindehi.

Name

       XML::XUpdate::LibXML - Simple implementation of XUpdate format

See Also

       XML::LibXML XML::LibXML::XPathContext

perl v5.32.0                                       2021-01-07                          XML::XUpdate::LibXML(3pm)

Synopsis

       use XML::LibXML; use XML::XUpdate::LibXML;

       $parser  = XML::LibXML->new(); $dom     = $parser->parse_file("mydoc.xml"); $actions =
       $parser->parse_file("update.xml");

       $xupdate = XML::XUpdate::LibXML->new(); $xupdate->process($dom->getDocumentElement(), $actions); print
       $dom->toString(),"\n";

See Also