EVOLUTION-MANAGER
Edit File: findXInclude.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Find the XInclude node associated with an XML node</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for findXInclude {XML}"><tr><td>findXInclude {XML}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Find the XInclude node associated with an XML node</h2> <h3>Description</h3> <p>This function is used to traverse the ancestors of an internal XML node to find the associated XInclude node that identifies it as being an XInclude'd node. Each top-level node that results from an include href=... in the libxml2 parser is sandwiched between nodes of class XMLXIncludeStartNode and XMLXIncludeStartNode. These are the sibling nodes. </p> <p>Another approach to finding the origin of the XInclude for a given node is to search for an attribute xml:base. This only works if the document being XInclude'd is in a different directory than the base document. If this is the case, we can use an XPath query to find the node containing the attribute via <code>"./ancestor::*[@xml:base]"</code>. </p> <h3>Usage</h3> <pre> findXInclude(x, asNode = FALSE, recursive = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>the node whose XInclude "ancestor" is to be found</p> </td></tr> <tr valign="top"><td><code>asNode</code></td> <td> <p>a logical value indicating whether to return the node itself or the attributes of the node which are typically the immediately interesting aspect of the node.</p> </td></tr> <tr valign="top"><td><code>recursive</code></td> <td> <p>a logical value that controls whether the full path of the nested includes is returned or just the path in the immediate XInclude element.</p> </td></tr> </table> <h3>Value</h3> <p>Either <code>NULL</code> if there was no node of class XMLXIncludeStartNode found. Otherwise, if <code>asNode</code> is <code>TRUE</code>, that XMLXIncludeStartNode node is returned, or alternatively its attribute character vector. </p> <h3>Author(s)</h3> <p>Duncan Temple Lang</p> <h3>References</h3> <p>www.libxml.org</p> <h3>See Also</h3> <p><code><a href="xmlTreeParse.html">xmlParse</a></code> and the <code>xinclude</code> parameter. </p> <h3>Examples</h3> <pre> f = system.file("exampleData", "functionTemplate.xml", package = "XML") cat(readLines(f), "\n") doc = xmlParse(f) # Get all the para nodes # We just want to look at the 2nd and 3rd which are repeats of the # first one. a = getNodeSet(doc, "//author") findXInclude(a[[1]]) i = findXInclude(a[[1]], TRUE) top = getSibling(i) # Determine the top-level included nodes tmp = getSibling(i) nodes = list() while(!inherits(tmp, "XMLXIncludeEndNode")) { nodes = c(nodes, tmp) tmp = getSibling(tmp) } </pre> <hr /><div style="text-align: center;">[Package <em>XML</em> version 3.99-0.3 <a href="00Index.html">Index</a>]</div> </body></html>