Blame | Last modification | View Log | Download | RSS feed
\name{findXInclude}\alias{findXInclude}%- Also NEED an '\alias' for EACH other topic documented here.\title{Find the XInclude node associated with an XML node}\description{This function is used to traverse the ancestors of aninternal XML node to find the associated XIncludenode that identifies it as being an XInclude'd node.Each top-level node that results from an include href=... in the libxml2 parseris sandwiched between nodes of classXMLXIncludeStartNode and XMLXIncludeStartNode.These are the sibling nodes.Another approach to finding the origin of the XInclude for a givennode is to search for an attribute xml:base. This only works if thedocument 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 nodecontaining the attribute via \code{"./ancestor::*[@xml:base]"}.}\usage{findXInclude(x, asNode = FALSE, recursive = FALSE)}\arguments{\item{x}{the node whose XInclude "ancestor" is to be found}\item{asNode}{a logical value indicating whether to return the node itself orthe attributes of the node which are typically the immediately interestingaspect of the node.}\item{recursive}{a logical value that controls whether thefull path of the nested includes is returned or just thepath in the immediate XInclude element.}}\value{Either \code{NULL} if there was no node of class XMLXIncludeStartNodefound.Otherwise, if \code{asNode} is \code{TRUE}, that XMLXIncludeStartNodenode is returned, or alternatively its attribute character vector.}\references{www.libxml.org}\author{Duncan Temple Lang}\seealso{\code{\link{xmlParse}} and the \code{xinclude} parameter.}\examples{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 nodestmp = getSibling(i)nodes = list()while(!inherits(tmp, "XMLXIncludeEndNode")) {nodes = c(nodes, tmp)tmp = getSibling(tmp)}}\keyword{IO}