Skip to content

Commit

Permalink
passes R CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
duncantl committed Oct 4, 2015
1 parent c708d64 commit 005015f
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 33 deletions.
14 changes: 13 additions & 1 deletion Changes
@@ -1,4 +1,16 @@
Version 3.98-1
Version 3.99-0

* We can specify R functions and C routines for use as XPath functions in calls to
getNodeSet() and xpathApply().

* Implementations of XPath 2.0 functions matches(), lower-case(), ends-with(), abs(), min(), max(), replace()

Version 3.98-2

* xmlSave() of a document to a file with encoding now honors indenting.
Uses xmlSaveFormatFileEnc(). Issue identified by Earl Brown.

Version 3.98-2

* xmlToS4() handles attributes with namespace prefixes and children
with the same node name.
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,9 +1,9 @@
Package: XML
Version: 3.98-1
Version: 3.99-0
Author: Duncan Temple Lang (duncan@r-project.org)
Maintainer: Duncan Temple Lang <duncan@r-project.org>
Title: Tools for parsing and generating XML within R and S-Plus.
Depends: R (>= 1.2.0), methods, utils
Title: Tools for parsing and generating XML within R and S-Plus
Depends: R (>= 1.2.0), utils
Imports: methods
Suggests: bitops, RCurl
SystemRequirements: libxml2 (>= 2.6.3)
Expand All @@ -19,7 +19,7 @@ Note: In version 2.4.0 of this package, a new approach to garbage collection has
the result of incrementing the minor count by 1 for each release.
Specifically, there is no change in the interface.
URL: http://www.omegahat.org/RSXML
License: BSD
License: BSD_3_clause + file LICENSE
Collate: AAA.R
DTD.R
DTDClasses.R
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION.in
@@ -1,9 +1,9 @@
Package: XML
Version: 3.98-1
Version: 3.98-3
Author: Duncan Temple Lang (duncan@r-project.org)
Maintainer: Duncan Temple Lang <duncan@r-project.org>
Title: Tools for parsing and generating XML within R and S-Plus.
Depends: R (>= 1.2.0), methods, utils
Title: Tools for parsing and generating XML within R and S-Plus
Depends: R (>= 1.2.0), utils
Imports: methods
Suggests: bitops, RCurl
SystemRequirements: libxml2 (>= 2.6.3)
Expand All @@ -19,7 +19,7 @@ Note: In version 2.4.0 of this package, a new approach to garbage collection has
the result of incrementing the minor count by 1 for each release.
Specifically, there is no change in the interface.
URL: http://www.omegahat.org/RSXML
License: BSD
License: BSD_3_clause + file LICENSE
Collate: AAA.R
DTD.R
DTDClasses.R
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Expand Up @@ -3,6 +3,7 @@

import(methods)


export(
append.xmlNode,
append.XMLNode,
Expand Down Expand Up @@ -225,6 +226,8 @@ S3method(xmlSize, XMLInternalNode)

S3method(xmlValue, XMLInternalNode)

S3method(xmlValue, XMLNodeSet)

#exportS3method("xmlValue", "NULL")
S3method("xmlValue", "NULL")

Expand Down Expand Up @@ -509,3 +512,4 @@ export(getHTMLExternalFiles)

export(xmlCleanNamespaces)

export(replaceNodeWithChildren)
1 change: 1 addition & 0 deletions NAMESPACE.in
Expand Up @@ -3,6 +3,7 @@

import(methods)


export(
append.xmlNode,
append.XMLNode,
Expand Down
27 changes: 13 additions & 14 deletions R/XMLClasses.R
Expand Up @@ -698,7 +698,7 @@ xpathApply =
#
#
function(doc, path, fun = NULL, ... , namespaces = xmlNamespaceDefinitions(doc, simplify = TRUE),
resolveNamespaces = TRUE, addFinalizer = NA)
resolveNamespaces = TRUE, addFinalizer = NA, xpathFuns = list())
{
UseMethod("xpathApply")
}
Expand All @@ -715,11 +715,11 @@ function(x, ...)

xpathApply.XMLNode =
function(doc, path, fun = NULL, ... , namespaces = xmlNamespaceDefinitions(doc, simplify = TRUE),
resolveNamespaces = TRUE, addFinalizer = NA, .node = NULL, noMatchOkay = FALSE)
resolveNamespaces = TRUE, addFinalizer = NA, xpathFuns = list(), .node = NULL, noMatchOkay = FALSE)
{
idoc = xmlParse(saveXML(doc), asText = TRUE)
ans = xpathApply(idoc, path, fun, ..., namespaces = namespaces, resolveNamespaces = resolveNamespaces,
.node = .node, noMatchOkay = noMatchOkay)
.node = .node, noMatchOkay = noMatchOkay, xpathFuns = xpathFuns)

# Now convert the results
if(length(ans))
Expand All @@ -731,9 +731,8 @@ function(doc, path, fun = NULL, ... , namespaces = xmlNamespaceDefinitions(doc,

xpathApply.XMLInternalDocument =
function(doc, path, fun = NULL, ... , namespaces = xmlNamespaceDefinitions(doc, simplify = TRUE),
resolveNamespaces = TRUE, addFinalizer = NA, .node = NULL, noMatchOkay = FALSE,
sessionEncoding = CE_NATIVE, noResultOk = FALSE,
xpathFuns = list()) # native
resolveNamespaces = TRUE, addFinalizer = NA, xpathFuns = list(), .node = NULL, noMatchOkay = FALSE,
sessionEncoding = CE_NATIVE, noResultOk = FALSE) # native
{
path = paste(path, collapse = " | ")

Expand Down Expand Up @@ -763,7 +762,7 @@ function(doc, path, fun = NULL, ... , namespaces = xmlNamespaceDefinitions(doc,
if(is.character(xpathFuns))
xpathFuns = as.list(xpathFuns)
else
anonFuns = xpathFuns[ sapply(xpathFuns, is.function) ]
anonFuns = xpathFuns[ vapply(xpathFuns, is.function, FALSE) ]


ans = .Call("RS_XML_xpathEval", doc, .node, as.character(path), namespaces, fun, encoding, addFinalizer, xpathFuns, anonFuns, PACKAGE = "XML")
Expand Down Expand Up @@ -896,7 +895,7 @@ xpathSubNodeApply =
#
function(doc, path, fun = NULL, ...,
namespaces = xmlNamespaceDefinitions(doc, simplify = TRUE),
resolveNamespaces = TRUE, addFinalizer = NA)
resolveNamespaces = TRUE, addFinalizer = NA, xpathFuns = list())
{
path = paste(path, collapse = " | ")

Expand Down Expand Up @@ -955,7 +954,7 @@ function(doc, path, fun = NULL, ...,
docName(doc) = paste("created for xpathApply for", path, "in node", xmlName(node))


ans = xpathApply(doc, path, NULL, namespaces = namespaces, resolveNamespaces = resolveNamespaces, addFinalizer = addFinalizer)
ans = xpathApply(doc, path, NULL, namespaces = namespaces, resolveNamespaces = resolveNamespaces, addFinalizer = addFinalizer, xpathFuns = xpathFuns)

if(length(ans) == 0)
return(ans)
Expand Down Expand Up @@ -987,27 +986,27 @@ if(TRUE)
xpathApply.XMLInternalNode =
function(doc, path, fun = NULL, ...,
namespaces = xmlNamespaceDefinitions(doc, simplify = TRUE),
resolveNamespaces = TRUE, addFinalizer = NA)
resolveNamespaces = TRUE, addFinalizer = NA, xpathFuns = list())
{
ndoc = as(doc, "XMLInternalDocument")
if(is.null(ndoc))
xpathSubNodeApply(doc, path, fun, ..., namespaces = namespaces, resolveNamespaces = resolveNamespaces, addFinalizer = addFinalizer)
xpathSubNodeApply(doc, path, fun, ..., namespaces = namespaces, resolveNamespaces = resolveNamespaces, addFinalizer = addFinalizer, xpathFuns = xpathFuns)
else
xpathApply.XMLInternalDocument(ndoc, path, fun, ...,
namespaces = namespaces, resolveNamespaces = resolveNamespaces,
.node = doc, addFinalizer = addFinalizer)
.node = doc, addFinalizer = addFinalizer, xpathFuns = xpathFuns)
}


xpathApply.XMLDocument =
#xpathApply.XMLNode =
function(doc, path, fun = NULL, ... , namespaces = xmlNamespaceDefinitions(doc, simplify = TRUE),
resolveNamespaces = TRUE, .node = NULL, addFinalizer = NA)
resolveNamespaces = TRUE, .node = NULL, addFinalizer = NA, xpathFuns = list())
{
txt = saveXML(doc)
doc = xmlParse(txt, asText = TRUE)
ans = xpathApply(doc, path, fun, ..., namespaces = namespaces, resolveNamespaces = resolveNamespaces, .node = .node,
addFinalizer = addFinalizer)
addFinalizer = addFinalizer, xpathFuns = xpathFuns)

if(length(ans))
ans = lapply(ans, toXMLNode)
Expand Down
3 changes: 1 addition & 2 deletions R/bitList.R
Expand Up @@ -2,14 +2,13 @@ bitlist =
# Taken from RAutoGenRuntime
function(...)
{
library(bitops)
x = unlist(list(...))
if(length(x) == 1)
return(x)

ans = x[1]
for(i in 2:length(x)) {
ans = bitOr(ans, x[i])
ans = bitops::bitOr(ans, x[i])
}
ans
}
14 changes: 12 additions & 2 deletions R/getRelativeURL.R
Expand Up @@ -18,6 +18,9 @@ getRelativeURL =
# getRelativeURL("../foo/xyz/bar.html", "http://www.omegahat.org/a/b.html")
#
#
# getRelativeURL("?page=2&searchterms=Data%20Science&searchlocation=&newsearch=true&sorttype=", "http://www.cybercoders.com/search"))
#
#
# BROKEN
# getRelativeURL("foo", ".") yields :///foo
#
Expand All @@ -27,12 +30,13 @@ getRelativeURL =
# getRelativeURL("../foo", "http://www.omegahat.org/a/b.html")
# should be http://www.omegahat.org/foo
# or at least http://www.omegahat.org/a/../foo
function(u, baseURL, sep = "/", addBase = TRUE, simplify = TRUE)
function(u, baseURL, sep = "/", addBase = TRUE, simplify = TRUE, escapeQuery = FALSE)
{
if(length(u) > 1)
return(sapply(u, getRelativeURL, baseURL, sep))

pu = parseURI(u)

#XXX Need to strip the path in baseURL if pu$path starts with /
if(pu$scheme == "" && addBase) {
b = parseURI(baseURL)
Expand All @@ -42,7 +46,13 @@ function(u, baseURL, sep = "/", addBase = TRUE, simplify = TRUE)
return(as(b, "character"))
}

b$path = sprintf("%s%s%s", dirname(b$path), sep, u)

endsWithSlash = grepl("/$", b$path)

if(endsWithSlash && grepl("^\\./", u))
u = substring(u, 3)

b$path = sprintf("%s%s%s", if(endsWithSlash) b$path else dirname(b$path), if(endsWithSlash) "" else sep, u)
# handle .. in the path and try to collapse these.
if(simplify && grepl("..", b$path, fixed = TRUE))
b$path = simplifyPath(b$path)
Expand Down
2 changes: 1 addition & 1 deletion man/getNodeSet.Rd
Expand Up @@ -108,7 +108,7 @@ xpathApply(doc, path, fun, ... ,
xpathSApply(doc, path, fun = NULL, ... ,
namespaces = xmlNamespaceDefinitions(doc, simplify = TRUE),
resolveNamespaces = TRUE, simplify = TRUE,
addFinalizer = NA, xpathFuns = list())
addFinalizer = NA)
matchNamespaces(doc, namespaces,
nsDefs = xmlNamespaceDefinitions(doc, recursive = TRUE, simplify = FALSE),
defaultNs = getDefaultNamespace(doc, simplify = TRUE))
Expand Down
5 changes: 3 additions & 2 deletions man/getRelativeURL.Rd
Expand Up @@ -13,7 +13,8 @@
relative directories such as "..".
}
\usage{
getRelativeURL(u, baseURL, sep = "/", addBase = TRUE, simplify = TRUE)
getRelativeURL(u, baseURL, sep = "/", addBase = TRUE,
simplify = TRUE, escapeQuery = FALSE)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
Expand All @@ -29,7 +30,7 @@ getRelativeURL(u, baseURL, sep = "/", addBase = TRUE, simplify = TRUE)
to the result.}
\item{simplify}{a logical value that controls whether we attempt to
simplify/normalize the path to remove \code{..} and \code{.}}

\item{escapeQuery}{a logical value. Currently ignored.}
}
\details{
This uses the function \code{parseURI} to compute the components
Expand Down
4 changes: 3 additions & 1 deletion man/getXIncludes.Rd
Expand Up @@ -15,7 +15,7 @@ getXIncludes(filename, recursive = TRUE, skip = character(),
namespace = c(xi = "http://www.w3.org/2003/XInclude"),
duplicated = TRUE)
xmlXIncludes(filename, recursive = TRUE,
omitPattern = "\\.(js|html?|txt|R|c)$",
omitPattern = "\\\\.(js|html?|txt|R|c)$",
namespace = c(xi = "http://www.w3.org/2003/XInclude"),
addNames = TRUE,
clean = NULL, ignoreTextParse = FALSE)
Expand Down Expand Up @@ -43,6 +43,8 @@ xmlXIncludes(filename, recursive = TRUE,
\code{gsub}.
The function is called with a vector of file names. The regular
expressions are used in a call to \code{gsub}.}
\item{ignoreTextParse}{if \code{TRUE}, ignore the XIncluded files that
are identified as text and not XML with \code{parse="text"}.}
}
\value{
If \code{recursive} is \code{FALSE}, a character vector giving the
Expand Down
2 changes: 1 addition & 1 deletion myTests/oldTests.R
Expand Up @@ -2,7 +2,7 @@ if(FALSE) {
# URL changed and the format of the data is now
# via <li> elements.

u = "http://weather.sfgate.com/auto/sfgate/geo/precip/index.html"
u = "http://weather.sfgate.com/auto/sfgate/geo/precip/index.html"
# header as a logical vector
tt = tryCatch(readHTMLTable(u,
header = c(FALSE, FALSE, TRUE, FALSE, FALSE)),
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.in
@@ -1,2 +1,2 @@
PKG_CPPFLAGS= @PKG_CPPFLAGS@ @LANGUAGE_DEFS@ @XMLSEC_DEFS@ -I. @LIBXML2@
PKG_CPPFLAGS= @PKG_CPPFLAGS@ @LANGUAGE_DEFS@ @XMLSEC_DEFS@ -I. @LIBXML2@
PKG_LIBS= @PKG_LIBS@

0 comments on commit 005015f

Please sign in to comment.