\name{parseGmModel} \alias{parseGmModel} \alias{xmlHypergraph} \title{Reads/writes a graphical model from the StatShop XML.} \description{ The function \code{parseGmModel} reads a StatShop \code{gm.xml} file and creates a \code{gmModel} object from it. The function \code{xmlHypergraph} creates an \code{XMLNode} representing the model. } \usage{ parseGmModel(filename, type) xmlHypergraph(model, toplevel = TRUE) } \arguments{ \item{filename}{Filename for \code{gm.xml} file.} \item{type}{Optional argument giving the type, should be one of "SM" or "EM/LM". If missing, will try and discover the type based on the presence or absence of a \code{} element.} \item{model}{An object of type \code{gmModel}} \item{toplevel}{A logical flag, if true the appropriate XML namespace and schema attributes are added to the top level node.} } \value{ For \sQuote{parseGmModel}, a \code{gmModel} object containig all of the variables and distributions in the \code{gm.xml} file. For \sQuote{xmlHypergraph} an \code{XMLNode} object containing the information for \code{model}. } \details{ The function \code{parseAMD} calls \code{parseGmModel} to the details for Student, Evidence and Link Models. The \code{type} argument is passed to indicate what type of model is expected. Usually the system can distinguish between Student and Evidence Models on the presense of \code{} vs \code{} tags in the XML. However, it can't currently distinguish between Evidence and Link Models without help. The function \code{xmlHypergraph} produces the XML code for the master file. It produces an object of type \code{XMLNode} (which \code{writeAMD} writes to \code{amdfile}). As this is the top level XML object, the constant \code{amdf.prefix} gives the namespace prefix and the constants \code{amdf.namespace} and \code{amdf.schemaLocation} provide details about the schema location. } \references{ \url{http://research.ets.org/~ralmond/StatShop/dataFormats.html} } \author{Russell Almond} \seealso{\code{\link{gmModel}},\code{\link{getGmModelFromNode}}, \code{\link[XML]{XMLNode}}, \code{\link{gm.namespace}}, \code{\link{gm.prefix}}, \code{\link{gm.schemaLocation}}, \code{\link{xmlWrite}}, \code{\link{parseAMD}}, } \examples{ # Assumes StatShop is installed on the test machine. StatShop <- Sys.getenv("STATSHOP") if (StatShop == "") { warn("StatShop not installed, skipping test.") } else { E5 <- parseGmModel(paste(StatShop,"TestScripts","ICT","Version0", "Hybrid","FixedContext","P4_EvaluateS5_EM.gm.xml", sep=.Platform$file.sep)) ## Write out the result ## Need a writeable directory. outdir <- ifelse(.Platform$OS.type == "windows", "C:/temp","/tmp") xmlWrite(xmlHypergraph(E5),paste(outdir,"E5testout.gm.xml", sep=.Platform$file.sep)) } } \keyword{interface}