getXIncludeFiles: Find all documents XInclude'd in this one

Description Usage Arguments Value See Also Examples

Description

This function finds all the XInclude nodes within this document and identifies the included documents. It can operate recursively, finding the included documents within each of those and so on. This is useful for determining if the files are included more than once, if some files in a directory are not included at all, and for obtaining a dependency list, e.g. for use with make rules.

This doesn't deal with XPointer qualifications at this point in time. See #rh-Details.

Usage

1
2
3
getXIncludeFiles(doc, recursive = TRUE, nodes = FALSE, full.names = TRUE, 
                  namespace = c(xi = "http://www.w3.org/2003/XInclude", xo = "http://www.w3.org/2001/XInclude"), 
                 verbose = FALSE, table = FALSE)

Arguments

doc

the XML document to be processed. This can be either the file name (or URL) or the already parsed XML document returned from xmlParse .

recursive

a logical value indicting whether to find the included documents within the included documents.

nodes

a logical value indicating whether we should return the XML include nodes, or the names of the files. This is useful if one wants to modify the nodes or get the xpointer attribute.

full.names

a logical value indicating whether we are to give full paths for the files. If this is FALSE, we use the names as they appear in the href attribute within the include nodes within the document.

namespace

a named character vector giving the namespace definitions for identifying XInclude. There are two in reasonably common use.

verbose

a logical indicating whether to emit information about which files are being processed as the search proceeds.

table

a logical value which indicates whether to return a frequency table of the include file names. This makes the result more compact if there are many repeated includes.

Value

The return value depends on the value of different arguments. If recursive is true and table is TRUE, a frequency table of the included files is returned. If table is FALSE however, then the character vector of all included file names is returned. If recursive is FALSE, then either the include nodes or the character vector of included files is returned. This is controlled by the value of nodes. In all cases, if the names of the files are being returned, the names are converted to normalized path names (typically fully-qualified names) if full.names is specified.

See Also

getNodeSet

http://www.w3.org/TR/xinclude/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  
    
  
     #  Finding XIncludes in a book
 #  This identifies the included files in a sample book that uses XInclude to 
 #  bring in the chapters from separate files and a section from separate file.
 #  
 #  It converts the file names to fully-qualified paths and operates recursively.
 #  This gives us the dependency list for the entire book (at the present instance).
f = system.file("sampleDocs", "book.xml", package = "XDocTools")
getXIncludeFiles(f, recursive = TRUE, full.names = TRUE)

  

omegahat/XDocTools documentation built on May 24, 2019, 1:57 p.m.