Blame | Last modification | View Log | Download | RSS feed
\name{ensureNamespace}\alias{ensureNamespace}\title{Ensure that the node has a definition for particular XML namespaces}\description{This function is a helper function for use in creating XML content.We often want to create a node that will be part of a larger XML treeand use a particular namespace for that node name. Rather thandefining the namespace in each new node, we want to ensure thatit is define on an ancestor node. This function aids in that task.We call the function with the ancestor node or top-level documentand have it check whether the namespace is already defined or haveit add it to the node and return.This is intended for use with \code{XMLInternalNode} objectswhich are direclty mutable (rather than changing a copy of the nodeand having to insert that back into the larger tree.)}\usage{ensureNamespace(doc, what)}\arguments{\item{doc}{an \code{XMLInternalDocument} or \code{XMLInternalNode} onwhich the namespace is to be defined. If this is a documentm, we usethe root node.}\item{what}{a named character vector giving the URIs for the namespacedefinitions and the names giving the desired prefixes}}\value{This is used for the potential side effects of modifying theXML node to add (some of) the namespaces as needed.}\references{XML namespaces}\author{Duncan Temple Lang}\seealso{\code{\link{newXMLNamespace}}\code{\link{newXMLNode}}}\examples{doc = newXMLDoc()top = newXMLNode("article", doc = doc)ensureNamespace(top, c(r = "http://www.r-project.org"))b = newXMLNode("r:code", parent = top)print(doc)}\keyword{IO}\concept{XML}