Perform the XInclude substitutions
processXInclude.RdThis function and its methods process the XInclude directives
within the document of the form <xi:include href="..."
xpointer=".."
and perform the actual substitution.
These are only relevant for "internal nodes" as generated
via xmlInternalTreeParse and
newXMLNode and their related functions.
When dealing with XML documents via xmlTreeParse
or xmlEventParse, the XInclude nodes are controlled
during the parsing.
Arguments
- node
an XMLInternalDocument object or an XMLInternalElement node or a list of such internal nodes, e.g. returned from
xpathApply.- flags
an integer value that provides information to control how the XInclude substitutions are done, i.e. how they are parsed. This is a bitwise OR'ing of some or all of the xmlParserOption values. This will be turned into an enum in R in the future.
References
libxml2 http://www.xmlsoft.org XInclude
Examples
f = system.file("exampleData", "include.xml", package = "XML")
doc = xmlInternalTreeParse(f, xinclude = FALSE)
cat(saveXML(doc))
#> <?xml version="1.0"?>
#> <doc xmlns:xi="http://www.w3.org/2001/XInclude">
#> <caveat>
#> <para>This is a caveat that we repeat often.</para>
#> </caveat>
#> <section>
#> <title>A</title>
#> <xi:include xpointer="xpointer(//caveat[1])"/>
#> </section>
#> <section>
#> <title>B</title>
#> <xi:include xpointer="xpointer(/doc/caveat)"/>
#> </section>
#> </doc>
sects = getNodeSet(doc, "//section")
sapply(sects, function(x) xmlName(x[[2]]))
#> [1] "include" "include"
processXInclude(doc)
#> [1] 2
cat(saveXML(doc))
#> <?xml version="1.0"?>
#> <doc xmlns:xi="http://www.w3.org/2001/XInclude">
#> <caveat>
#> <para>This is a caveat that we repeat often.</para>
#> </caveat>
#> <section>
#> <title>A</title>
#> <caveat>
#> <para>This is a caveat that we repeat often.</para>
#> </caveat>
#> </section>
#> <section>
#> <title>B</title>
#> <caveat>
#> <para>This is a caveat that we repeat often.</para>
#> </caveat>
#> </section>
#> </doc>
f = system.file("exampleData", "include.xml", package = "XML")
doc = xmlInternalTreeParse(f, xinclude = FALSE)
section1 = getNodeSet(doc, "//section")[[1]]
# process
processXInclude(section1[[2]])
#> NULL