Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

set default value of encoding parameter to getEncoding().

  • Loading branch information...
commit e38bbe64a9765d8b055710ceb1a193f173a3d999 1 parent 0fb9ade
Duncan Temple Lang duncantl authored
Showing with 18 additions and 17 deletions.
  1. +8 −8 Src/nodeAccessors.R
  2. +9 −8 Src/saveXML.R
  3. +1 −1  Src/xmlNodes.R
16 Src/nodeAccessors.R
View
@@ -91,18 +91,18 @@ function(X, FUN, ...)
xmlValue <-
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
{
UseMethod("xmlValue")
}
if(useS4)
- setGeneric("xmlValue", function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+ setGeneric("xmlValue", function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
standardGeneric("xmlValue"))
xmlValue.XMLNode <-
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
{
if(recursive && xmlSize(x) > 0) {
kids = xmlChildren(x)
@@ -128,7 +128,7 @@ function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
setS3Method("xmlValue", "XMLNode")
xmlValue.XMLTextNode <-
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
{
if(!is.null(x$value))
x$value
@@ -139,7 +139,7 @@ function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
setS3Method("xmlValue", "XMLTextNode")
xmlValue.XMLComment <- xmlValue.XMLCommentNode <-
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
{
if(ignoreComments)
return("")
@@ -153,7 +153,7 @@ function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
setS3Method("xmlValue", "XMLCommentNode")
xmlValue.XMLCDataNode <-
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
{
x$value
}
@@ -161,7 +161,7 @@ function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
setS3Method("xmlValue", "XMLCDataNode")
xmlValue.XMLProcessingInstruction <-
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
{
x$value
}
@@ -169,7 +169,7 @@ function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
setS3Method("xmlValue", "XMLProcessingInstruction")
"xmlValue.NULL" =
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x))
as.character(NA)
#setS3Method("xmlValue", "NULL")
17 Src/saveXML.R
View
@@ -1,7 +1,7 @@
if(FALSE) {
saveXML <-
function(doc, file=NULL, compression=0, indent=TRUE, prefix = '<?xml version="1.0"?>\n',
- doctype = NULL, encoding = "", ...)
+ doctype = NULL, encoding = getEncoding(doc), ...)
{
UseMethod("saveXML")
}
@@ -10,12 +10,13 @@ function(doc, file=NULL, compression=0, indent=TRUE, prefix = '<?xml version="1.
saveXML.XMLInternalNode <-
function(doc, file = NULL, compression = 0, indent = TRUE, prefix = '<?xml version="1.0"?>\n',
- doctype = NULL, encoding = "", ...)
+ doctype = NULL, encoding = getEncoding(doc), ...)
{
if(encoding == "")
encoding = character()
- ans = .Call("RS_XML_printXMLNode", doc, as.integer(0), as.integer(indent), as.logical(indent), as.character(encoding), PACKAGE = "XML")
+ ans = .Call("RS_XML_printXMLNode", doc, as.integer(0), as.integer(indent),
+ as.logical(indent), as.character(encoding), PACKAGE = "XML")
if(length(file)) {
cat(ans, file = file)
@@ -28,7 +29,7 @@ function(doc, file = NULL, compression = 0, indent = TRUE, prefix = '<?xml versi
saveXML.XMLInternalDocument <-
function(doc, file = NULL, compression = 0, indent = TRUE,
- prefix = '<?xml version="1.0"?>\n', doctype = NULL, encoding = "", ...)
+ prefix = '<?xml version="1.0"?>\n', doctype = NULL, encoding = getEncoding(doc), ...)
{
havePrefix = !missing(prefix)
@@ -77,7 +78,7 @@ function(doc, file = NULL, compression = 0, indent = TRUE,
saveXML.XMLInternalDOM <-
function(doc, file=NULL, compression=0, indent=TRUE, prefix = '<?xml version="1.0"?>\n',
- doctype = NULL, encoding = "", ...)
+ doctype = NULL, encoding = getEncodong(doc), ...)
{
saveXML(doc$value(), file, compression, indent, prefix, doctype, encoding)
}
@@ -85,7 +86,7 @@ function(doc, file=NULL, compression=0, indent=TRUE, prefix = '<?xml version="1.
saveXML.XMLOutputStream =
function(doc, file = NULL, compression = 0, indent = TRUE, prefix = '<?xml version="1.0"?>\n',
- doctype = NULL, encoding = "", ...)
+ doctype = NULL, encoding = getEncoding(doc), ...)
{
saveXML(doc$value(), file, compression, indent, prefix, doctype, encoding)
}
@@ -96,7 +97,7 @@ saveXML.sink =
# Need to handle a DTD here as the prefix argument..
#
function(doc, file = NULL, compression = 0, indent = TRUE, prefix = '<?xml version="1.0"?>\n',
- doctype = NULL, encoding = "", ...)
+ doctype = NULL, encoding = getEncoding(x), ...)
{
asString = is.null(file)
if(asString)
@@ -132,7 +133,7 @@ saveXML.XMLFlatTree = saveXML.sink
setGeneric("saveXML",
function(doc, file=NULL, compression=0, indent=TRUE, prefix = '<?xml version="1.0"?>\n',
- doctype = NULL, encoding = "", ...)
+ doctype = NULL, encoding = getEncoding(doc), ...)
standardGeneric("saveXML"))
setMethod("saveXML", "XMLInternalNode", saveXML.XMLInternalNode)
2  Src/xmlNodes.R
View
@@ -197,7 +197,7 @@ function(x, i, j, ..., addFinalizer = NA)
xmlValue.XMLInternalNode =
-function(x, ignoreComments = FALSE, recursive = TRUE, encoding = CE_NATIVE)
+function(x, ignoreComments = FALSE, recursive = TRUE, encoding = getEncoding(x)) #CE_NATIVE)
{
encoding = if(is.integer(encoding))
Please sign in to comment.
Something went wrong with that request. Please try again.