[rkward-cvs] SF.net SVN: rkward:[4175] trunk/rkward/packages/XiMpLe

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Tue Mar 13 16:16:21 UTC 2012


Revision: 4175
          http://rkward.svn.sourceforge.net/rkward/?rev=4175&view=rev
Author:   m-eik
Date:     2012-03-13 16:16:21 +0000 (Tue, 13 Mar 2012)
Log Message:
-----------
parseXMLTree() can now parse character vectors directly, pasteXMLNode() doesn't add empty lines after text values

Modified Paths:
--------------
    trunk/rkward/packages/XiMpLe/ChangeLog
    trunk/rkward/packages/XiMpLe/DESCRIPTION
    trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R
    trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R
    trunk/rkward/packages/XiMpLe/R/parseXMLTree.R
    trunk/rkward/packages/XiMpLe/R/pasteXMLNode.R
    trunk/rkward/packages/XiMpLe/inst/CITATION
    trunk/rkward/packages/XiMpLe/inst/NEWS.Rd
    trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd
    trunk/rkward/packages/XiMpLe/man/parseXMLTree.Rd

Modified: trunk/rkward/packages/XiMpLe/ChangeLog
===================================================================
--- trunk/rkward/packages/XiMpLe/ChangeLog	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/ChangeLog	2012-03-13 16:16:21 UTC (rev 4175)
@@ -1,5 +1,10 @@
 ChangeLog for package XiMpLe
 
+changes in version 0.03-11 (2012-03-13)
+  - added opton "object" to parseXMLTree(), to be able to parse XML trees not only from files, but also character vectors
+  - output of internal function XML.single.tags() has no colname any more
+  - text values of nodes are no longer followed by an empty newline in pasteXMLNode()
+
 changes in version 0.03-10 (2012-03-11)
   - fixed bug in parsing of attributes, their names are now all quoted by default o not run into issues
     if they contain R-sensitive characters (like "http-equiv")

Modified: trunk/rkward/packages/XiMpLe/DESCRIPTION
===================================================================
--- trunk/rkward/packages/XiMpLe/DESCRIPTION	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/DESCRIPTION	2012-03-13 16:16:21 UTC (rev 4175)
@@ -17,8 +17,8 @@
 URL: http://reaktanz.de/?c=hacking&s=XiMpLe
 Authors at R: c(person(given="Meik", family="Michalke",
     email="meik.michalke at hhu.de", role=c("aut", "cre")))
-Version: 0.03-10
-Date: 2012-03-11
+Version: 0.03-11
+Date: 2012-03-13
 Collate:
     'XiMpLe.node-class.R'
     'XiMpLe.doc-class.R'

Modified: trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R	2012-03-13 16:16:21 UTC (rev 4175)
@@ -69,7 +69,7 @@
 					return(split.chars(txt=this.tree, "<(.*?)>"))
 				}
 			}))
-	names(single.tags) <- NULL
+	colnames(single.tags) <- NULL
 	if("comments" %in% drop){
 		single.tags <- single.tags[!XML.comment(single.tags)]
 	} else {}

Modified: trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/R/XiMpLe-package.R	2012-03-13 16:16:21 UTC (rev 4175)
@@ -3,8 +3,8 @@
 #' \tabular{ll}{
 #' Package: \tab XiMpLe\cr
 #' Type: \tab Package\cr
-#' Version: \tab 0.03-10\cr
-#' Date: \tab 2012-03-11\cr
+#' Version: \tab 0.03-11\cr
+#' Date: \tab 2012-03-13\cr
 #' Depends: \tab R (>= 2.9.0),methods\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr

Modified: trunk/rkward/packages/XiMpLe/R/parseXMLTree.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/parseXMLTree.R	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/R/parseXMLTree.R	2012-03-13 16:16:21 UTC (rev 4175)
@@ -4,9 +4,11 @@
 #' @param drop Character vector with the possible values \code{"comments"}, \code{"cdata"}
 #'		\code{"declarations"} and \code{"doctype"}, defining element classes to be dropped
 #'		from the resulting object.
+#' @param object Logical, if \code{TRUE}, \code{file} will not be treated as a path name but as a
+#'		character vector to be parsed as XML directly.
 #' @return An object of class \code{XiMpLe.doc} with four slots:
 #'		\describe{
-#'			\item{\code{file}:}{Full path to the parsed file.}
+#'			\item{\code{file}:}{Full path to the parsed file, or \code{"object"} if \code{object=TRUE}.}
 #'			\item{\code{xml}:}{XML declaration, if found.}
 #'			\item{\code{dtd}:}{Doctype definition, if found.}
 #'			\item{\code{children}:}{A list of objects of class \code{XiMpLe.node}, with the elements
@@ -16,8 +18,14 @@
 #'		}
 #' @export
 
-parseXMLTree <- function(file, drop=NULL){
-	xml.raw <- paste(readLines(file), collapse=" ")
+parseXMLTree <- function(file, drop=NULL, object=FALSE){
+	if(isTRUE(object)){
+		xml.raw <- paste(file, collapse=" ")
+		filePath <- "object"
+	} else {
+		xml.raw <- paste(readLines(file), collapse=" ")
+		filePath <- normalizePath(file)
+	}
 
 	single.tags <- XML.single.tags(xml.raw, drop=drop)
 
@@ -38,7 +46,7 @@
 	children <- XML.nodes(single.tags)[["children"]]
 	
 	results <- new("XiMpLe.doc",
-		file=normalizePath(file),
+		file=filePath,
 		xml=XML.decl,
 		dtd=XML.doct,
 		children=children)

Modified: trunk/rkward/packages/XiMpLe/R/pasteXMLNode.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/pasteXMLNode.R	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/R/pasteXMLNode.R	2012-03-13 16:16:21 UTC (rev 4175)
@@ -53,7 +53,7 @@
 			if(isTRUE(tidy)){
 				node.val <- sapply(node.val, xml.tidy)
 			} else {}
-			node.chld <- paste(new.indent, paste(node.val, collapse=" "), new.node, sep="")
+			node.chld <- paste(new.indent, paste(node.val, collapse=" "), sep="")
 		} else {}
 	} else {}
 

Modified: trunk/rkward/packages/XiMpLe/inst/CITATION
===================================================================
--- trunk/rkward/packages/XiMpLe/inst/CITATION	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/inst/CITATION	2012-03-13 16:16:21 UTC (rev 4175)
@@ -2,12 +2,12 @@
 		title="XiMpLe: A simple XML tree parser and generator",
 		author="Meik Michalke",
 		year="2012",
-		note="(Version 0.03-10)",
+		note="(Version 0.03-11)",
 		url="http://reaktanz.de/?c=hacking&s=XiMpLe",
 
 		textVersion =
 		paste("Michalke, M. (2012). ",
-				"XiMpLe: A simple XML tree parser and generator (Version 0.03-10). ",
+				"XiMpLe: A simple XML tree parser and generator (Version 0.03-11). ",
 				"Available from http://reaktanz.de/?c=hacking&s=XiMpLe",
 				sep=""),
 

Modified: trunk/rkward/packages/XiMpLe/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/XiMpLe/inst/NEWS.Rd	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/inst/NEWS.Rd	2012-03-13 16:16:21 UTC (rev 4175)
@@ -1,6 +1,13 @@
 \name{NEWS}
 \title{News for Package 'XiMpLe'}
 \encoding{UTF-8}
+\section{Changes in XiMpLe version 0.03-11 (2012-03-13)}{
+  \itemize{
+    \item added opton \code{"object"} to \code{parseXMLTree()}, to be able to parse XML trees not only from files, but also character vectors
+    \item output of internal function \code{XML.single.tags()} has no colname any more
+    \item text values of nodes are no longer followed by an empty newline in \code{pasteXMLNode()}
+  }
+}
 \section{Changes in XiMpLe version 0.03-10 (2012-03-11)}{
   \itemize{
     \item fixed bug in parsing of attributes, their names are now all quoted by default o not run into issues

Modified: trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd
===================================================================
--- trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/man/XiMpLe-package.Rd	2012-03-13 16:16:21 UTC (rev 4175)
@@ -8,8 +8,8 @@
 }
 \details{
   \tabular{ll}{ Package: \tab XiMpLe\cr Type: \tab
-  Package\cr Version: \tab 0.03-10\cr Date: \tab
-  2012-03-11\cr Depends: \tab R (>= 2.9.0),methods\cr
+  Package\cr Version: \tab 0.03-11\cr Date: \tab
+  2012-03-13\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/parseXMLTree.Rd
===================================================================
--- trunk/rkward/packages/XiMpLe/man/parseXMLTree.Rd	2012-03-11 21:44:11 UTC (rev 4174)
+++ trunk/rkward/packages/XiMpLe/man/parseXMLTree.Rd	2012-03-13 16:16:21 UTC (rev 4175)
@@ -2,7 +2,7 @@
 \alias{parseXMLTree}
 \title{Read an XML file into an R object}
 \usage{
-  parseXMLTree(file, drop = NULL)
+  parseXMLTree(file, drop = NULL, object = FALSE)
 }
 \arguments{
   \item{file}{Character string, valid path to the XML file
@@ -12,11 +12,16 @@
   \code{"comments"}, \code{"cdata"} \code{"declarations"}
   and \code{"doctype"}, defining element classes to be
   dropped from the resulting object.}
+
+  \item{object}{Logical, if \code{TRUE}, \code{file} will
+  not be treated as a path name but as a character vector
+  to be parsed as XML directly.}
 }
 \value{
   An object of class \code{XiMpLe.doc} with four slots:
   \describe{ \item{\code{file}:}{Full path to the parsed
-  file.} \item{\code{xml}:}{XML declaration, if found.}
+  file, or \code{"object"} if \code{object=TRUE}.}
+  \item{\code{xml}:}{XML declaration, if found.}
   \item{\code{dtd}:}{Doctype definition, if found.}
   \item{\code{children}:}{A list of objects of class
   \code{XiMpLe.node}, with the elements \code{"name"} (the

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