[rkward-cvs] SF.net SVN: rkward:[4186] trunk/rkward/packages/XiMpLe
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Sat Mar 17 22:40:26 UTC 2012
Revision: 4186
http://rkward.svn.sourceforge.net/rkward/?rev=4186&view=rev
Author: m-eik
Date: 2012-03-17 22:40:26 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
XiMpLe: fixed almost all paste issues (still slightly wrong indentadion for nodes inside comments), HTML tidying is now more reliable, too.
Modified Paths:
--------------
trunk/rkward/packages/XiMpLe/ChangeLog
trunk/rkward/packages/XiMpLe/DESCRIPTION
trunk/rkward/packages/XiMpLe/R/XMLNode.R
trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R
trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R
trunk/rkward/packages/XiMpLe/R/pasteXML-methods.R
trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R
trunk/rkward/packages/XiMpLe/inst/NEWS.Rd
trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd
trunk/rkward/packages/XiMpLe/man/pasteXML-methods.Rd
Modified: trunk/rkward/packages/XiMpLe/ChangeLog
===================================================================
--- trunk/rkward/packages/XiMpLe/ChangeLog 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/ChangeLog 2012-03-17 22:40:26 UTC (rev 4186)
@@ -1,11 +1,12 @@
ChangeLog for package XiMpLe
-changes in version 0.03-12 (2012-03-16)
+changes in version 0.03-12 (2012-03-17)
- node() now also works with single XiMpLe.node objects (not only full trees)
- added pasteXML methods to paste objects of classes XiMpLe.node and XiMpLe.doc in a more
general manner. the former functions pasteXMLNode() and pasteXMLTree() are replaced by mere
wrapper frunctions to pasteXML() and should not be used any longer.
- fixed dropped text value if node also had child nodes in pasteXML()
+ - fixed missing quotes in DOCTYPE id (pasteXML())
changes in version 0.03-11 (2012-03-14)
- added functions XMLNode() and XMLTree() as constructor functions for XML nodes and trees.
Modified: trunk/rkward/packages/XiMpLe/DESCRIPTION
===================================================================
--- trunk/rkward/packages/XiMpLe/DESCRIPTION 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/DESCRIPTION 2012-03-17 22:40:26 UTC (rev 4186)
@@ -6,12 +6,11 @@
Depends:
R (>= 2.9.0),methods
Enhances: rkward
-Description: This package provides a simple XML tree parser/generator.
- It includes functions to read XML files into R objects, get
- information out of and into nodes, and write R objects back to
- XML code. It's not as powerful as the XML package and doesn't
- aim to be, but for simple XML handling it could be useful. It
- was originally programmed for RKWard.
+Description: This package provides a simple XML tree parser/generator. It
+ includes functions to read XML files into R objects, get information out of
+ and into nodes, and write R objects back to XML code. It's not as powerful
+ as the XML package and doesn't aim to be, but for simple XML handling it
+ could be useful. It was originally programmed for RKWard.
License: GPL (>= 3)
Encoding: UTF-8
LazyLoad: yes
@@ -19,7 +18,7 @@
Authors at R: c(person(given="Meik", family="Michalke",
email="meik.michalke at hhu.de", role=c("aut", "cre")))
Version: 0.03-12
-Date: 2012-03-16
+Date: 2012-03-17
Collate:
'XiMpLe-internal.R'
'XiMpLe.node-class.R'
Modified: trunk/rkward/packages/XiMpLe/R/XMLNode.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/XMLNode.R 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/R/XMLNode.R 2012-03-17 22:40:26 UTC (rev 4186)
@@ -17,24 +17,24 @@
XMLNode <- function(name, ..., attrs=NULL, namespace="", namespaceDefinitions=NULL, .children=list(...)){
+ all.children <- list()
+
# text node?
if(identical(name, "") &
(all(unlist(lapply(.children, is.character)))) |
all(unlist(lapply(.children, is.numeric)))){
- all.children <- list()
value <- paste(..., sep=" ")
} else if(identical(.children, list(""))){
- all.children <- list()
value <- ""
} else {
# remove NULLs
.children <- .children[unlist(lapply(.children, length) != 0)]
# check for text values
all.children <- sapply(child.list(.children), function(this.child){
- if(is.character(this.child)){
+ if(is.character(this.child) | is.numeric(this.child)){
this.child <- new("XiMpLe.node",
name="",
- value=this.child
+ value=as.character(this.child)
)
} else {}
return(this.child)
Modified: trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R 2012-03-17 22:40:26 UTC (rev 4186)
@@ -114,7 +114,7 @@
# with harmless entities
xml.tidy <- function(text){
if(is.character(text)){
- tidy.text <- gsub("<", "<", gsub(">", ">", gsub("([[:space:]])&([[:space:]])", "\\1&\\2", text, perl=TRUE)))
+ tidy.text <- gsub("<", "<", gsub(">", ">", gsub("&([#[:alnum:]]{7}[^;]|[[:space:]]|[^;]*$)", "&\\1", text, perl=TRUE)))
} else {
return(text)
}
Modified: trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R 2012-03-17 22:40:26 UTC (rev 4186)
@@ -4,7 +4,7 @@
#' Package: \tab XiMpLe\cr
#' Type: \tab Package\cr
#' Version: \tab 0.03-12\cr
-#' Date: \tab 2012-03-16\cr
+#' Date: \tab 2012-03-17\cr
#' Depends: \tab R (>= 2.9.0),methods\cr
#' Enhances: \tab rkward\cr
#' Encoding: \tab UTF-8\cr
Modified: trunk/rkward/packages/XiMpLe/R/pasteXML-methods.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/pasteXML-methods.R 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/R/pasteXML-methods.R 2012-03-17 22:40:26 UTC (rev 4186)
@@ -1,7 +1,7 @@
#' Paste methods for XiMpLe XML objects
#'
-#' These methods can be used to paste objects if class \code{\link[XiMpLe:XiMpLe.node]{XiMpLe.node}}
-#' or \code{\link[XiMpLe:XiMpLe.doc]{XiMpLe.doc}}.
+#' These methods can be used to paste objects if class \code{\link[XiMpLe:XiMpLe.node-class]{XiMpLe.node}}
+#' or \code{\link[XiMpLe:XiMpLe.doc-class]{XiMpLe.doc}}.
#'
#' @note The functions pasteXMLNode() and pasteXMLTree() have been replaced by the pasteXML methods.
#' They should no longer be used.
@@ -55,7 +55,12 @@
if(length(node.chld) > 0){
node.chld <- paste(unlist(sapply(node.chld, function(this.node){
- return(pasteXMLNode(this.node, level=(level + 1), shine=shine, indent.by=indent.by, tidy=tidy))})), collapse="", sep="")
+ if(slot(this.node, "name") == ""){
+ this.node.pasted <- paste(new.indent, pasteXML(this.node, level=level, shine=shine, indent.by=indent.by, tidy=tidy), sep="")
+ } else {
+ this.node.pasted <- pasteXML(this.node, level=(level + 1), shine=shine, indent.by=indent.by, tidy=tidy)
+ }
+ return(this.node.pasted)})), collapse="", sep="")
node.empty <- FALSE
} else {
node.chld <- NULL
@@ -69,7 +74,7 @@
if(isTRUE(tidy)){
node.val <- sapply(node.val, xml.tidy)
} else {}
- node.chld <- paste(node.chld, paste(new.indent, node.val, new.node, collapse=" "), sep="")
+ node.chld <- paste(node.chld, paste(node.val, new.node, collapse=" "), sep="")
} else {}
} else {}
@@ -101,12 +106,14 @@
if(any(nchar(unlist(tree.doctype)) > 0)) {
new.node <- ifelse(shine > 0, "\n", "")
- doc.doctype <- paste("<!DOCTYPE ", paste(tree.doctype[["doctype"]], tree.doctype[["id"]], sep=" "), sep="")
- if(length(tree.doctype[["refer"]]) > 0) {
- if(nchar(tree.doctype[["refer"]]) > 0){
- doc.doctype <- paste(doc.doctype, " \"",tree.doctype[["refer"]], "\"", sep="")
+ doc.doctype <- paste("<!DOCTYPE ", tree.doctype[["doctype"]], sep="")
+ for (elmt in c("id", "refer")){
+ if(length(tree.doctype[[elmt]]) > 0) {
+ if(nchar(tree.doctype[[elmt]]) > 0){
+ doc.doctype <- paste(doc.doctype, " \"",tree.doctype[[elmt]], "\"", sep="")
+ } else {}
} else {}
- } else {}
+ }
doc.doctype <- paste(doc.doctype, ">", new.node, sep="")
} else {
doc.doctype <- ""
@@ -114,7 +121,7 @@
if(length(tree.nodes) > 0) {
doc.nodes <- paste(unlist(sapply(tree.nodes, function(this.node){
- return(pasteXMLNode(this.node, level=1, shine=shine, indent.by=indent.by, tidy=tidy))})), collapse="", sep="")
+ return(pasteXML(this.node, level=1, shine=shine, indent.by=indent.by, tidy=tidy))})), collapse="", sep="")
} else {
doc.nodes <- ""
}
Modified: trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R 2012-03-17 22:40:26 UTC (rev 4186)
@@ -42,7 +42,7 @@
# three special cases: value pseudotags, comments and CDATA
if(isTRUE(nchar(tag) == 0) | length(tag) == 0){
- full.tag <- paste(new.indent, child, new.node, sep="")
+ full.tag <- paste(child, " ", sep="")
} else if(identical(tag, "!--")){
# clean up value if needed
if(!is.null(child)){
@@ -70,14 +70,14 @@
new.attr <- ifelse((length(attr) > 1), new.attr, "")
new.attr.indent <- ifelse((length(attr) > 1), new.attr.indent, "")
new.cmmt.indent <- ifelse((length(attr) > 1), new.cmmt.indent, "")
- val.indent <- ifelse(shine > 1, indent(level + 1, by=indent.by), "")
+ val.indent <- ifelse(shine > 0, indent(level + 1, by=indent.by), "")
# empty decides whether this is a empty tag or a pair of start and end tags
if(isTRUE(empty)){
full.tag <- paste(new.indent, "<", tag, attr.space, new.attr, new.cmmt.indent, all.attributes, new.attr, new.attr.indent, " />", new.node, sep="")
} else {
full.tag <- paste(
new.indent, "<", tag, attr.space, new.attr, new.cmmt.indent, all.attributes, new.attr, new.attr.indent, ">", new.node,
- if(!is.null(child)){paste(val.indent, child, sep="")},
+ if(!is.null(child)){paste(val.indent, trim(child), new.node, sep="")},
new.indent, "</", tag, ">", new.node, sep="")
}
}
Modified: trunk/rkward/packages/XiMpLe/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/XiMpLe/inst/NEWS.Rd 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/inst/NEWS.Rd 2012-03-17 22:40:26 UTC (rev 4186)
@@ -1,13 +1,14 @@
\name{NEWS}
\title{News for Package 'XiMpLe'}
\encoding{UTF-8}
-\section{Changes in XiMpLe version 0.03-12 (2012-03-16)}{
+\section{Changes in XiMpLe version 0.03-12 (2012-03-17)}{
\itemize{
\item \code{node()} now also works with single XiMpLe.node objects (not only full trees)
\item added pasteXML methods to paste objects of classes XiMpLe.node and XiMpLe.doc in a more
general manner. the former functions \code{pasteXMLNode()} and \code{pasteXMLTree()} are replaced by mere
wrapper frunctions to \code{pasteXML()} and should not be used any longer.
\item fixed dropped text value if node also had child nodes in \code{pasteXML()}
+ \item fixed missing quotes in DOCTYPE id (\code{pasteXML()})
}
}
\section{Changes in XiMpLe version 0.03-11 (2012-03-14)}{
Modified: trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd
===================================================================
--- trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd 2012-03-17 22:40:26 UTC (rev 4186)
@@ -9,7 +9,7 @@
\details{
\tabular{ll}{ Package: \tab XiMpLe\cr Type: \tab
Package\cr Version: \tab 0.03-12\cr Date: \tab
- 2012-03-16\cr Depends: \tab R (>= 2.9.0),methods\cr
+ 2012-03-17\cr Depends: \tab R (>= 2.9.0),methods\cr
Enhances: \tab rkward\cr Encoding: \tab UTF-8\cr License:
\tab GPL (>= 3)\cr LazyLoad: \tab yes\cr URL: \tab
http://reaktanz.de/?c=hacking&s=XiMpLe\cr }
Modified: trunk/rkward/packages/XiMpLe/man/pasteXML-methods.Rd
===================================================================
--- trunk/rkward/packages/XiMpLe/man/pasteXML-methods.Rd 2012-03-17 17:03:53 UTC (rev 4185)
+++ trunk/rkward/packages/XiMpLe/man/pasteXML-methods.Rd 2012-03-17 22:40:26 UTC (rev 4186)
@@ -27,8 +27,8 @@
}
\description{
These methods can be used to paste objects if class
- \code{\link[XiMpLe:XiMpLe.node]{XiMpLe.node}} or
- \code{\link[XiMpLe:XiMpLe.doc]{XiMpLe.doc}}.
+ \code{\link[XiMpLe:XiMpLe.node-class]{XiMpLe.node}} or
+ \code{\link[XiMpLe:XiMpLe.doc-class]{XiMpLe.doc}}.
}
\note{
The functions pasteXMLNode() and pasteXMLTree() have been
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list