[rkward-cvs] SF.net SVN: rkward:[4189] trunk/rkward/packages/rkwarddev

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Sun Mar 18 22:01:13 UTC 2012


Revision: 4189
          http://rkward.svn.sourceforge.net/rkward/?rev=4189&view=rev
Author:   m-eik
Date:     2012-03-18 22:01:13 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
rkwarddev: some more cleaning up, moving checks for node validity to internal functions valid.child() and valid.parent()

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.components.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.context.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.copy.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.dialog.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.hierarchy.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.logic.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.menu.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.page.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.wizard.R
    trunk/rkward/packages/rkwarddev/R/rk.comment.R
    trunk/rkward/packages/rkwarddev/R/rk.rkh.settings.R
    trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2012-03-18 22:01:13 UTC (rev 4189)
@@ -1,10 +1,12 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.05-3 (2012-03-17)
+changes in version 0.05-3 (2012-03-18)
   - fixed: rk.XML.text() now preserves XML tags in the text value
-  - functions now call XiMpLe::XMLNode() and XiMpLe::XMLTree() constructors instead of new(), and
-    pasteXMLNode() and pasteXMLTree() were globally renamed into pasteXML()
+  - internally, functions now call XiMpLe::XMLNode() and XiMpLe::XMLTree() constructors instead of new(),
+    and pasteXMLNode() and pasteXMLTree() were globally renamed into pasteXML()
   - internally, replaced object at node with slot(object, "node")
+  - internally, moved checks for valid child and parent nodes to an internal functions,
+    valid.child() and valid.parent()
 
 changes in version 0.05-2 (2012-03-10)
   - added missing dependency to package methods

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -501,6 +501,98 @@
 } ## end function modif.validity()
 
 
+## list with valid child nodes
+# important for certain parent nodes, as long as
+# XiMpLe doesn't interpret doctypes
+all.valid.children <- list(
+	# 'as' is not a node, but an attribute of <copy>
+	as=c("browser", "checkbox", "column", "copy",
+		"dropdown", "formula", "frame", "input", "page", "radio", "row", "saveobject",
+		"spinbox", "stretch", "tabbook", "text", "varselector", "varslot"),
+	components=c("component"),
+	context=c("menu", "!--"),
+	dialog=c("browser", "checkbox", "column", "copy",
+		"dropdown", "embed", "formula", "frame", "include", "input", "insert",
+		"preview", "radio", "row", "saveobject", "spinbox", "stretch", "tabbook",
+		"text", "varselector", "varslot", "!--"),
+	hierarchy=c("menu", "!--"),
+	logic=c("connect", "convert","include","insert","external","set","script"),
+	menu=c("entry", "menu", "!--"),
+	page=c("browser", "checkbox", "column", "copy",
+		"dropdown", "formula", "frame", "input", "page", "radio", "row", "saveobject",
+		"spinbox", "stretch", "tabbook", "text", "varselector", "varslot", "!--"),
+	settings=c("setting", "caption", "!--"),
+	wizard=c("browser", "checkbox", "column", "copy",
+		"dropdown", "embed", "formula", "frame", "include", "input", "insert",
+		"page", "preview", "radio", "row", "saveobject", "spinbox", "stretch",
+		"tabbook", "text", "varselector", "varslot", "!--")
+) ## end list with valid child nodes
+
+
+## function valid.child()
+# - parent: character string, name of the parent node
+# - children: (list of) XiMpLe.node objects, child nodes to check
+# - warn: warning or stop?
+# - section: an optional name for the section for the warning/error
+#   (if it shouldn't be the parent name)
+# - node names: can alternatively be given instead of 'children', as character vector
+valid.child <- function(parent, children, warn=FALSE, section=parent, node.names=NULL){
+	if(is.null(node.names)){
+		# check the node names and allow only valid ones
+		node.names <- sapply(child.list(children), function(this.child){
+				if(inherits(this.child, "XiMpLe.node")){
+					return(slot(this.child, "name"))
+				} else {
+					stop(simpleError(paste("Invalid object for ", section, " section, must be of class XiMpLe.node, but got class ", class(this.child), "!", sep="")))
+				}
+			})
+	} else {}
+
+	invalid.sets <- !node.names %in% all.valid.children[[parent]]
+	if(any(invalid.sets)){
+		return.message <- paste("Invalid XML nodes for ", section, " section: ", paste(node.names[invalid.sets], collapse=", "), sep="")
+		if(isTRUE(warn)){
+			warning(return.message)
+			return(FALSE)
+		} else {
+			stop(simpleError(return.message))
+		}
+	} else {
+		return(TRUE)
+	}
+} ## end function valid.child()
+
+
+## function valid.parent()
+# checks if a node is what it's supposed to be
+# - parent: character string, name of the parent node
+# - node: a XiMpLe.node object to check
+# - warn: warning or stop?
+# - see: name of the function to check docs for
+valid.parent <- function(parent, node, warn=FALSE, see=NULL){
+	if(inherits(node, "XiMpLe.node")){
+		node.name <- slot(node, "name")
+		if(identical(node.name, parent)){
+			return(TRUE)
+		} else {
+			return.message <- paste("I don't know what this is, but '", parent, "' is not a <", parent, "> section!", sep="")
+			if(isTRUE(warn)){
+				warning(return.message)
+				return(FALSE)
+			} else {
+				stop(simpleError(return.message))
+			}
+		}
+	} else {
+		stop(simpleError(
+				paste("'", parent, "' must be a XiMpLe.node",
+					if(!is.null(see)){paste(", see ?", see, sep="")},
+					"!", sep=""))
+			)
+	}
+} ## end function valid.parent()
+
+
 ## function check.type()
 check.type <- function(value, type, var.name, warn.only=TRUE){
 	if(inherits(value, type)){

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.components.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.components.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.components.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -18,12 +18,7 @@
 	nodes <- list(...)
 
 	# check the node names and allow only valid ones
-	sapply(child.list(nodes), function(this.node){
-			node.name <- slot(this.node, "name")
-			if(!identical(node.name, "component")){
-				stop(simpleError(paste("Invalid XML nodes for components section: ", node.name, sep="")))
-			} else {}
-		})
+	valid.child("components", children=nodes)
 
 	node <- XMLNode("components", .children=child.list(nodes, empty=FALSE))
 

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.context.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.context.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.context.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -23,20 +23,12 @@
 	nodes <- list(...)
 
 	# check the node names and allow only valid ones
-	node.names <- sapply(child.list(nodes), function(this.node){
-			slot(this.node, "name")
-		})
+	valid.child("context", children=nodes)
 
 	if(!id %in% c("x11", "import")){
 		stop(simpleError(paste("Invalid ID: ", id, sep="")))
 	} else {}
 		
-	invalid.sets <- !node.names %in% c("menu", "!--")
-	if(any(invalid.sets)){
-		stop(simpleError(paste("Invalid XML nodes for context section: ",
-			paste(node.names[invalid.sets], collapse=", "), sep="")))
-	} else {}
-
 	node <- XMLNode("context",
 			attrs=list(id=id),
 			.children=child.list(nodes, empty=FALSE)

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.copy.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.copy.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.copy.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -30,14 +30,9 @@
 	attr.list <- list(id=id.name)
 
 	if(!is.null(as)){
-		invalid.sets <- !as %in% c("browser", "checkbox", "column", "copy",
-			"dropdown", "formula", "frame", "input", "page", "radio", "row", "saveobject",
-			"spinbox", "stretch", "tabbook", "text", "varselector", "varslot")
-		if(any(invalid.sets)){
-			stop(simpleError(paste("Invalid XML nodes ('as') for wizard/dialog section: ", paste(as, collapse=", "), sep="")))
-		} else {
-				attr.list[["as"]] <- as.character(as)
-		}
+		# check the validity
+		valid.child("as", node.names=as, section="wizard/dialog (copy/'as')")
+		attr.list[["as"]] <- as.character(as)
 	} else {}
 
 	node <- XMLNode("copy", attrs=attr.list)

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.dialog.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.dialog.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.dialog.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -24,18 +24,8 @@
 	nodes <- list(...)
 
 	# check the node names and allow only valid ones
-	node.names <- sapply(child.list(nodes), function(this.node){
-			slot(this.node, "name")
-		})
+	valid.child("dialog", children=nodes)
 
-	invalid.sets <- !node.names %in% c("browser", "checkbox", "column", "copy",
-		"dropdown", "embed", "formula", "frame", "include", "input", "insert",
-		"preview", "radio", "row", "saveobject", "spinbox", "stretch", "tabbook",
-		"text", "varselector", "varslot", "!--")
-	if(any(invalid.sets)){
-		stop(simpleError(paste("Invalid XML nodes for dialog section: ", paste(node.names[invalid.sets], collapse=", "), sep="")))
-	} else {}
-
 	if(!is.null(label)){
 		attr.list <- list(label=label)
 	} else {

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.hierarchy.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.hierarchy.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.hierarchy.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -23,16 +23,8 @@
 	nodes <- list(...)
 
 	# check the node names and allow only valid ones
-	node.names <- sapply(child.list(nodes), function(this.node){
-			slot(this.node, "name")
-		})
+	valid.child("hierarchy", children=nodes)
 
-	invalid.sets <- !node.names %in% c("menu", "!--")
-	if(any(invalid.sets)){
-		stop(simpleError(paste("Invalid XML nodes for hierarchy section: ",
-			paste(node.names[invalid.sets], collapse=", "), sep="")))
-	} else {}
-
 	node <- XMLNode("hierarchy", .children=child.list(nodes, empty=FALSE))
 
 	return(node)

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.logic.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.logic.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.logic.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -43,15 +43,8 @@
 		})
 
 	# check the node names and allow only valid ones
-	node.names <- sapply(child.list(nodes), function(this.node){
-			slot(this.node, "name")
-		})
+	valid.child("logic", children=nodes)
 
-	invalid.sets <- !node.names %in% c("connect", "convert","include","insert","external","set","script")
-	if(any(invalid.sets)){
-		stop(simpleError(paste("Invalid XML nodes for logic section: ", paste(node.names[invalid.sets], collapse=", "), sep="")))
-	} else {}
-
 	node <- XMLNode("logic", .children=child.list(nodes, empty=FALSE))
 
 	return(node)

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.menu.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.menu.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.menu.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -84,13 +84,7 @@
 	} else {}
 
 	# check the node names and allow only valid ones
-	sapply(child.list(nodes), function(this.node){
-			stopifnot(inherits(this.node, "XiMpLe.node"))
-			node.name <- slot(this.node, "name")
-			if(!node.name %in% c("entry", "menu", "!--")){
-				stop(simpleError(paste("Invalid XML nodes for menu section: ", node.name, sep="")))
-			} else {}
-		})
+	valid.child("menu", children=nodes)
 
 	if(identical(id.name, "auto")){
 		# try autogenerating some id

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.page.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.page.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.page.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -26,17 +26,8 @@
 	nodes <- list(...)
 
 	# check the node names and allow only valid ones
-	node.names <- sapply(child.list(nodes), function(this.node){
-			slot(this.node, "name")
-		})
+	valid.child("page", children=nodes, section="page/wizard")
 
-	invalid.sets <- !node.names %in% c("browser", "checkbox", "column", "copy",
-		"dropdown", "formula", "frame", "input", "page", "radio", "row", "saveobject",
-		"spinbox", "stretch", "tabbook", "text", "varselector", "varslot", "!--")
-	if(any(invalid.sets)){
-		stop(simpleError(paste("Invalid XML nodes for page/wizard section: ", paste(node.names[invalid.sets], collapse=", "), sep="")))
-	} else {}
-
 	if(identical(id.name, "auto")){
 		# try autogenerating some id
 		attr.list <- list(id=auto.ids(node.soup(nodes), prefix=ID.prefix("page"), chars=10))

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -65,29 +65,14 @@
 	} else {}
 
 	if(!is.null(about)){
-		if(inherits(about, "XiMpLe.node")){
-			about.node.name <- slot(about, "name")
-			# check if this is *really* a about section, otherwise quit and go dancing
-			if(!identical(about.node.name, "about")){
-				stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
-			} else {
-				all.children[[length(all.children)+1]] <- about
-			}
-		} else {
-			stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
-		}
+		# check if this is *really* an about section, otherwise quit and go dancing
+		valid.parent("about", node=about, see="rk.XML.about")
+		all.children[[length(all.children)+1]] <- about
 	} else {}
 
 	if(!is.null(snippets)){
 		# check if this is *really* a snippets section, otherwise quit and go dancing
-		if(inherits(snippets, "XiMpLe.node")){
-			snippets.node.name <- slot(snippets, "name")
-		} else {
-			snippets.node.name <- "yougottabekiddingme"
-		}
-		if(!identical(snippets.node.name, "snippets")){
-			stop(simpleError("I don't know what this is, but 'snippets' is not a snippets section!"))
-		} else {}
+		valid.parent("snippets", node=snippets, see="rk.XML.snippets")
 		all.children[[length(all.children)+1]] <- snippets
 	} else {}
 
@@ -102,14 +87,7 @@
 		} else {}
 	} else {
 		# check if this is *really* a logic section, otherwise quit and go dancing
-		if(inherits(logic, "XiMpLe.node")){
-			logic.node.name <- slot(logic, "name")
-		} else {
-			logic.node.name <- "yougottabekiddingme"
-		}
-		if(!identical(logic.node.name, "logic")){
-			stop(simpleError("I don't know what this is, but 'logic' is not a logic section!"))
-		} else {}
+		valid.parent("logic", node=logic, see="rk.XML.logic")
 		all.children[[length(all.children)+1]] <- logic
 	}
 
@@ -119,14 +97,7 @@
 		} else {}
 	} else {
 		# check if this is *really* a dialog section
-		if(inherits(dialog, "XiMpLe.node")){
-			dialog.node.name <- slot(dialog, "name")
-		} else {
-			dialog.node.name <- "yougottabekiddingme"
-		}
-		if(!identical(dialog.node.name, "dialog")){
-			stop(simpleError("I don't know what this is, but 'dialog' is not a dialog section!"))
-		} else {}
+		valid.parent("dialog", node=dialog, see="rk.XML.dialog")
 		all.children[[length(all.children)+1]] <- dialog
 	}
 
@@ -139,14 +110,7 @@
 		} else {}
 	} else {
 		# check if this is *really* a wizard section
-		if(inherits(wizard, "XiMpLe.node")){
-			wizard.node.name <- slot(wizard, "name")
-		} else {
-			wizard.node.name <- "yougottabekiddingme"
-		}
-		if(!identical(wizard.node.name, "wizard")){
-			stop(simpleError("I don't know what this is, but 'wizard' is not a wizard section!"))
-		} else {}
+		valid.parent("wizard", node=wizard, see="rk.XML.wizard")
 		all.children[[length(all.children)+1]] <- wizard
 	}
 

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -59,18 +59,10 @@
 
 	## about section
 	if(!is.null(about)){
-		if(inherits(about, "XiMpLe.node")){
-			about.node.name <- slot(about, "name")
-			# check if this is *really* a about section, otherwise quit and go dancing
-			if(!identical(about.node.name, "about")){
-				stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
-			} else {
-				# initialize all.children list
-				all.children[[length(all.children)+1]] <- about
-			}
-		} else {
-			stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
-		}
+		# check if this is *really* a about section, otherwise quit and go dancing
+		valid.parent("about", node=about, see="rk.XML.about")
+		# initialize all.children list
+		all.children[[length(all.children)+1]] <- about
 	} else {
 		if(isTRUE(hints)){
 			about.XML <- XMLNode("!--", XMLNode("about", ""))
@@ -84,12 +76,8 @@
 		# check if this is *really* require nodes
 		for(this.child in child.list(require)){
 				if(inherits(this.child, "XiMpLe.node")){
-					node.name <- slot(this.child, "name")
-					if(!identical(node.name, "require")){
-						stop(simpleError("I don't know what this is, but 'require' is not made of require nodes!"))
-					} else {
-						all.children[[length(all.children)+1]] <- this.child
-					}
+					valid.parent("require", node=this.child, see="rk.XML.require")
+					all.children[[length(all.children)+1]] <- this.child
 				} else {
 					if(grepl(".pluginmap", this.child)){
 						all.children[[length(all.children)+1]] <- rk.XML.require(file=this.child)
@@ -107,11 +95,8 @@
 
 	## components section
 	if(inherits(components, "XiMpLe.node")){
-		components.node.name <- slot(components, "name")
 		# check if this is *really* a components section, otherwise quit and go dancing
-		if(!identical(components.node.name, "components")){
-			stop(simpleError("I don't know what this is, but 'components' is not a components section!"))
-		} else {}
+		valid.parent("components", node=components, see="rk.XML.components")
 		all.children[[length(all.children)+1]] <- components
 		# get the IDs for hierarchy section
 		component.IDs <- sapply(slot(components, "children"), function(this.comp){
@@ -152,11 +137,8 @@
 
 	## hierachy section
 	if(inherits(hierarchy, "XiMpLe.node")){
-		hierarchy.node.name <- slot(hierarchy, "name")
 		# check if this is *really* a hierarchy section, otherwise quit and go dancing
-		if(!identical(hierarchy.node.name, "hierarchy")){
-			stop(simpleError("I don't know what this is, but 'hierarchy' is not a hierarchy section!"))
-		} else {}
+		valid.parent("hierarchy", node=hierarchy, see="rk.XML.hierarchy")
 		all.children[[length(all.children)+1]] <- hierarchy
 	} else {
 		# correct for cases with one component and a list

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.wizard.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.wizard.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.wizard.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -25,18 +25,8 @@
 	nodes <- list(...)
 
 	# check the node names and allow only valid ones
-	node.names <- sapply(child.list(nodes), function(this.node){
-			slot(this.node, "name")
-		})
+	valid.child("wizard", children=nodes)
 
-	invalid.sets <- !node.names %in% c("browser", "checkbox", "column", "copy",
-		"dropdown", "embed", "formula", "frame", "include", "input", "insert",
-		"page", "preview", "radio", "row", "saveobject", "spinbox", "stretch",
-		"tabbook", "text", "varselector", "varslot", "!--")
-	if(any(invalid.sets)){
-		stop(simpleError(paste("Invalid XML nodes for wizard section: ", paste(node.names[invalid.sets], collapse=", "), sep="")))
-	} else {}
-
 	if(!is.null(label)){
 		attr.list <- list(label=label)
 	} else {

Modified: trunk/rkward/packages/rkwarddev/R/rk.comment.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.comment.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.comment.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -8,6 +8,5 @@
 #' cat(pasteXML(test.comment))
 
 rk.comment <- function(text){
-	node <- XMLNode(name="!--", text)
-	return(node)
+	return(XMLNode(name="!--", text))
 }

Modified: trunk/rkward/packages/rkwarddev/R/rk.rkh.settings.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.rkh.settings.R	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/R/rk.rkh.settings.R	2012-03-18 22:01:13 UTC (rev 4189)
@@ -26,15 +26,8 @@
 	nodes <- list(...)
 
 	# check the node names and allow only valid ones
-	node.names <- sapply(child.list(nodes), function(this.node){
-			slot(this.node, "name")
-		})
+	valid.child("settings", children=nodes)
 
-	invalid.sets <- !node.names %in% c("setting", "caption", "!--")
-	if(any(invalid.sets)){
-		stop(simpleError(paste("Invalid XML nodes for settings section: ", paste(node.names[invalid.sets], collapse=", "), sep="")))
-	} else {}
-
 	node <- XMLNode("settings", .children=child.list(nodes, empty=FALSE))
 
 	return(node)

Modified: trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2012-03-18 16:24:48 UTC (rev 4188)
+++ trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2012-03-18 22:01:13 UTC (rev 4189)
@@ -1,12 +1,14 @@
 \name{NEWS}
 \title{News for Package 'rkwarddev'}
 \encoding{UTF-8}
-\section{Changes in rkwarddev version 0.05-3 (2012-03-17)}{
+\section{Changes in rkwarddev version 0.05-3 (2012-03-18)}{
   \itemize{
     \item fixed: \code{rk.XML.text()} now preserves XML tags in the text value
-    \item functions now call \code{XiMpLe::XMLNode()} and \code{XiMpLe::XMLTree()} constructors instead of \code{new()}, and
-      \code{pasteXMLNode()} and \code{pasteXMLTree()} were globally renamed into \code{pasteXML()}
+    \item internally, functions now call \code{XiMpLe::XMLNode()} and \code{XiMpLe::XMLTree()} constructors instead of \code{new()},
+      and \code{pasteXMLNode()} and \code{pasteXMLTree()} were globally renamed into \code{pasteXML()}
     \item internally, replaced object at node with slot(object, \code{"node"})
+    \item internally, moved checks for valid child and parent nodes to an internal functions,
+      \code{valid.child()} and \code{valid.parent()}
   }
 }
 \section{Changes in rkwarddev version 0.05-2 (2012-03-10)}{

Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)

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