findXInclude(XML)
findXInclude()所属R语言包:XML
Find the XInclude node associated with an XML node
查找一个XML节点与节点的XInclude
译者:生物统计家园网 机器人LoveR
描述----------Description----------
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.
此功能用于遍历内部的XML节点的祖先找到相关的XInclude,它标识,作为一个XIncluded节点的节点。每个顶级节点,从结果包括HREF = ...在libxml2解析器之间夹着的类XMLXIncludeStartNode和XMLXIncludeStartNode的节点。这些都是同级节点。
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 "./ancestor::*[@xml:base]".
发现一个给定节点的XInclude的起源的另一种方法是搜索的xml:base属性。这只是工作,如果的文件被XIncluded的是在不同的目录的基础文件。如果是这样的话,我们可以使用XPath查询,找到包含属性的节点通过"./ancestor::*[@xml:base]"。
用法----------Usage----------
findXInclude(x, asNode = FALSE)
参数----------Arguments----------
参数:x
the node whose XInclude "ancestor" is to be found
节点的XInclude的“祖先”是被发现
参数:asNode
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.
一个逻辑值,该值指示是否返回节点本身或通常紧接有趣的方面的节点的节点的属性。
值----------Value----------
Either NULL if there was no node of class XMLXIncludeStartNode found. Otherwise, if asNode is TRUE, that XMLXIncludeStartNode node is returned, or alternatively its attribute character vector.
无论是NULL如果有发现是没有类XMLXIncludeStartNode的节点。否则,如果asNode是TRUE,XMLXIncludeStartNode节点返回,或者其属性的字符向量。
(作者)----------Author(s)----------
Duncan Temple Lang
参考文献----------References----------
<h3>See Also</h3> <code>xmlParse</code> and the <code>xinclude</code> 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 nodes[确定顶级节点]
tmp = getSibling(i)
nodes = list()
while(!inherits(tmp, "XMLXIncludeEndNode")) {
nodes = c(nodes, tmp)
tmp = getSibling(tmp)
}
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|