Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getXIncludes

Find the documents that are XInclude'd in an XML document


Description

The getXMLIncludes function finds the names of the documents that are XIncluded in a given XML document, optionally processing these documents recursively.

xmlXIncludes returns the hierarchy of included documents.

Usage

getXIncludes(filename, recursive = TRUE, skip = character(),
             omitPattern = "\\.(js|html?|txt|R|c)$",
             namespace = c(xi = "http://www.w3.org/2003/XInclude"),
            duplicated = TRUE)
xmlXIncludes(filename, recursive = TRUE,
         omitPattern = "\\.(js|html?|txt|R|c)$",
         namespace = c(xi = "http://www.w3.org/2003/XInclude"),
         addNames = TRUE,
         clean = NULL, ignoreTextParse = FALSE)

Arguments

filename

the name of the XML document's URL or file or the parsed document itself.

recursive

a logical value controlling whether to recursively process the XInclude'd files for their XInclude'd files

skip

a character vector of file names to ignore or skip over

omitPattern

a regular expression for indentifying files that are included that we do not want to recursively process

namespace

the namespace to use for the XInclude. There are two that are in use 2001 and 2003.

duplicated

a logical value that controls whether only the unique names of the files are returned, or if we get all references to all files.

addNames

a logical that controls whether we add the name of the parent file as the names vector for the collection of included file names. This is useful, but sometimes we want to disable this, e.g. to create a JSON representation of the hierarchy for use in, e.g., D3.

clean

how to process the names of the files. This can be a function or a character vector of two regular expressions passed to gsub. The function is called with a vector of file names. The regular expressions are used in a call to gsub.

ignoreTextParse

if TRUE, ignore the XIncluded files that are identified as text and not XML with parse="text".

Value

If recursive is FALSE, a character vector giving the names of the included files.

For recursive is TRUE, currently the same character vector form. However, this will be a hierarchical list.

Author(s)

Duncan Temple Lang

See Also

Examples

f = system.file("exampleData", "xinclude", "a.xml", package = "XML")

  getXIncludes(f, recursive = FALSE)

XML

Tools for Parsing and Generating XML Within R and S-Plus

v3.99-0.10
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>), Tomas Kalibera [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.