Running examples in ‘XML-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: xmlTreeParse
> ### Title: XML Parser
> ### Aliases: xmlTreeParse htmlTreeParse htmlParse xmlInternalTreeParse
> ###   xmlNativeTreeParse xmlParse xmlSchemaParse
> ### Keywords: file IO
> 
> ### ** Examples
> 
>  fileName <- system.file("exampleData", "test.xml", package="XML")
>    # parse the document and return it in its standard format.
> 
>  xmlTreeParse(fileName)
$doc
$file
[1] "/home/hornik/tmp/R.check/r-patched-gcc/Work/build/Packages/XML/exampleData/test.xml"

$version
[1] "1.0"

$children
$children$comment
<!--A comment-->

$children$foo
<foo x="1">
 <element attrib1="my value"/>
  test entity bar <?R sum(rnorm(100))?>
 <a>
  <!--A comment-->
  <b>%extEnt;</b>
 </a>
 <![CDATA[
 This is escaped data
 containing < and &. ]]>
 Note that this caused a segmentation fault if replaceEntities was 
not TRUE.
That is,
 <code>xmlTreeParse(&quot;test.xml&quot;, replaceEntities = TRUE)</code>
 works, but
 <code>xmlTreeParse(&quot;test.xml&quot;)</code>
 does not if this is called before the one above.
This is now fixed and was caused by
treating an xmlNodePtr in the C code 
that had type XML_ELEMENT_DECL
and so was in fact an xmlElementPtr.
Aaah, C and casting!
</foo>


attr(,"class")
[1] "XMLDocumentContent"

$dtd
$external
NULL

$internal
$elements
$elements$y
$name
[1] "y"

$type
element 
     15 

$contents
$type
Element 
      2 

$ocur
Mult 
   3 

$elements
[1] "x"

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"

$elements$x
$name
[1] "x"

$type
mixed 
   15 

$contents
$type
PCData 
     1 

$ocur
Once 
   1 

$elements
NULL

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"


$entities
$entities$testEnt
$name
[1] "testEnt"

$value
[1] "test entity bar"

$original
[1] "test entity bar"

attr(,"class")
[1] "XMLEntity"

$entities$logo
$name
[1] "logo"

$value
[1] "gif"

$original
NULL

attr(,"class")
[1] "XMLEntity"


attr(,"class")
[1] "InternalDTD"

attr(,"class")
[1] "DTDList"

attr(,"class")
[1] "XMLDocument"         "XMLAbstractDocument"
> 
>    # parse the document, discarding comments.
>   
>  xmlTreeParse(fileName, handlers=list("comment"=function(x,...){NULL}), asTree = TRUE)
$doc
$file
[1] "/home/hornik/tmp/R.check/r-patched-gcc/Work/build/Packages/XML/exampleData/test.xml"

$version
[1] "1.0"

$children
$children$foo
<foo x="1">
 <element attrib1="my value"/>
  test entity bar <?R sum(rnorm(100))?>
 <a>
  <b>%extEnt;</b>
 </a>
 <![CDATA[
 This is escaped data
 containing < and &. ]]>
 Note that this caused a segmentation fault if replaceEntities was 
not TRUE.
That is,
 <code>xmlTreeParse(&quot;test.xml&quot;, replaceEntities = TRUE)</code>
 works, but
 <code>xmlTreeParse(&quot;test.xml&quot;)</code>
 does not if this is called before the one above.
This is now fixed and was caused by
treating an xmlNodePtr in the C code 
that had type XML_ELEMENT_DECL
and so was in fact an xmlElementPtr.
Aaah, C and casting!
</foo>


attr(,"class")
[1] "XMLDocumentContent"

$dtd
$external
NULL

$internal
$elements
$elements$x
$name
[1] "x"

$type
mixed 
   15 

$contents
$type
PCData 
     1 

$ocur
Once 
   1 

$elements
NULL

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"

$elements$y
$name
[1] "y"

$type
element 
     15 

$contents
$type
Element 
      2 

$ocur
Mult 
   3 

$elements
[1] "x"

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"


$entities
$entities$testEnt
$name
[1] "testEnt"

$value
[1] "test entity bar"

$original
[1] "test entity bar"

attr(,"class")
[1] "XMLEntity"

$entities$logo
$name
[1] "logo"

$value
[1] "gif"

$original
NULL

attr(,"class")
[1] "XMLEntity"


attr(,"class")
[1] "InternalDTD"

attr(,"class")
[1] "DTDList"

attr(,"class")
[1] "XMLDocument"         "XMLAbstractDocument"
> 
>    # print the entities
>  invisible(xmlTreeParse(fileName,
+             handlers=list(entity=function(x) {
+                                     cat("In entity",x$name, x$value,"\n")
+                                     x}
+                                   ), asTree = TRUE
+                           )
+           )
In entity testEnt test entity bar 
> 
>  # Parse some XML text.
>  # Read the text from the file
>  xmlText <- paste(readLines(fileName), "\n", collapse="")
> 
>  print(xmlText)
[1] "<?xml version=\"1.0\" ?> \n<!DOCTYPE foo [ \n  <!ENTITY % bar \"for R and S\"> \n  <!ENTITY % foo \"for Omegahat\"> \n \n  <!ENTITY testEnt \"test entity bar\"> \n  <!ENTITY logo SYSTEM \"images/logo.gif\" NDATA gif> \n  <!ENTITY % extEnt SYSTEM \"http://www.omegahat.net\">   <!-- include the contents of the README file in the same directory as this one. --> \n \n  <!ELEMENT x  (#PCDATA) > \n  <!ELEMENT y  (x)* > \n]> \n<!-- A comment --> \n<foo x=\"1\"> \n <element attrib1=\"my value\" /> \n &testEnt; \n <?R sum(rnorm(100)) ?> \n <a> \n  <!-- A comment --> \n  <b>  \n    %extEnt; \n  </b> \n </a> \n<![CDATA[ \n This is escaped data \n containing < and &. \n]]> \n \nNote that this caused a segmentation fault if replaceEntities was  \nnot TRUE. \nThat is, \n<code> \nxmlTreeParse(\"test.xml\", replaceEntities = TRUE) \n</code> \nworks, but  \n<code> \nxmlTreeParse(\"test.xml\") \n</code> \ndoes not if this is called before the one above. \nThis is now fixed and was caused by \ntreating an xmlNodePtr in the C code  \nthat had type XML_ELEMENT_DECL \nand so was in fact an xmlElementPtr. \nAaah, C and casting! \n</foo> \n"
>  xmlTreeParse(xmlText, asText=TRUE)
$doc
$file
[1] "<buffer>"

$version
[1] "1.0"

$children
$children$comment
<!--A comment-->

$children$foo
<foo x="1">
 <element attrib1="my value"/>
  test entity bar <?R sum(rnorm(100))?>
 <a>
  <!--A comment-->
  <b>%extEnt;</b>
 </a>
 <![CDATA[
 This is escaped data 
 containing < and &. ]]>
 Note that this caused a segmentation fault if replaceEntities was  
not TRUE. 
That is,
 <code>xmlTreeParse(&quot;test.xml&quot;, replaceEntities = TRUE)</code>
 works, but
 <code>xmlTreeParse(&quot;test.xml&quot;)</code>
 does not if this is called before the one above. 
This is now fixed and was caused by 
treating an xmlNodePtr in the C code  
that had type XML_ELEMENT_DECL 
and so was in fact an xmlElementPtr. 
Aaah, C and casting!
</foo>


attr(,"class")
[1] "XMLDocumentContent"

$dtd
$external
NULL

$internal
$elements
$elements$y
$name
[1] "y"

$type
element 
     15 

$contents
$type
Element 
      2 

$ocur
Mult 
   3 

$elements
[1] "x"

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"

$elements$x
$name
[1] "x"

$type
mixed 
   15 

$contents
$type
PCData 
     1 

$ocur
Once 
   1 

$elements
NULL

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"


$entities
$entities$logo
$name
[1] "logo"

$value
[1] "gif"

$original
NULL

attr(,"class")
[1] "XMLEntity"

$entities$testEnt
$name
[1] "testEnt"

$value
[1] "test entity bar"

$original
[1] "test entity bar"

attr(,"class")
[1] "XMLEntity"


attr(,"class")
[1] "InternalDTD"

attr(,"class")
[1] "DTDList"

attr(,"class")
[1] "XMLDocument"         "XMLAbstractDocument"
> 
> 
>     # with version 1.4.2 we can pass the contents of an XML
>     # stream without pasting them.
>  xmlTreeParse(readLines(fileName), asText=TRUE)
$doc
$file
[1] "<buffer>"

$version
[1] "1.0"

$children
$children$comment
<!--A comment-->

$children$foo
<foo x="1">
 <element attrib1="my value"/>
  test entity bar <?R sum(rnorm(100))?>
 <a>
  <!--A comment-->
  <b>%extEnt;</b>
 </a>
 <![CDATA[
 This is escaped data
 containing < and &. ]]>
 Note that this caused a segmentation fault if replaceEntities was 
not TRUE.
That is,
 <code>xmlTreeParse(&quot;test.xml&quot;, replaceEntities = TRUE)</code>
 works, but
 <code>xmlTreeParse(&quot;test.xml&quot;)</code>
 does not if this is called before the one above.
This is now fixed and was caused by
treating an xmlNodePtr in the C code 
that had type XML_ELEMENT_DECL
and so was in fact an xmlElementPtr.
Aaah, C and casting!
</foo>


attr(,"class")
[1] "XMLDocumentContent"

$dtd
$external
NULL

$internal
$elements
$elements$x
$name
[1] "x"

$type
mixed 
   15 

$contents
$type
PCData 
     1 

$ocur
Once 
   1 

$elements
NULL

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"

$elements$y
$name
[1] "y"

$type
element 
     15 

$contents
$type
Element 
      2 

$ocur
Mult 
   3 

$elements
[1] "x"

attr(,"class")
[1] "XMLElementContent"

$attributes
NULL

attr(,"class")
[1] "XMLElementDef"


$entities
$entities$logo
$name
[1] "logo"

$value
[1] "gif"

$original
NULL

attr(,"class")
[1] "XMLEntity"

$entities$testEnt
$name
[1] "testEnt"

$value
[1] "test entity bar"

$original
[1] "test entity bar"

attr(,"class")
[1] "XMLEntity"


attr(,"class")
[1] "InternalDTD"

attr(,"class")
[1] "DTDList"

attr(,"class")
[1] "XMLDocument"         "XMLAbstractDocument"
> 
> 
>  # Read a MathML document and convert each node
>  # so that the primary class is 
>  #   <name of tag>MathML
>  # so that we can use method  dispatching when processing
>  # it rather than conditional statements on the tag name.
>  # See plotMathML() in examples/.
>  fileName <- system.file("exampleData", "mathml.xml",package="XML")
> m <- xmlTreeParse(fileName, 
+                   handlers=list(
+                    startElement = function(node){
+                    cname <- paste(xmlName(node),"MathML", sep="",collapse="")
+                    class(node) <- c(cname, class(node)); 
+                    node
+                 }))
> 
> 
> 
>   # In this example, we extract _just_ the names of the
>   # variables in the mtcars.xml file. 
>   # The names are the contents of the <variable>
>   # tags. We discard all other tags by returning NULL
>   # from the startElement handler.
>   #
>   # We cumulate the names of variables in a character
>   # vector named 'vars'.
>   # We define this within a closure and define the 
>   # variable function within that closure so that it
>   # will be invoked when the parser encounters a <variable>
>   # tag.
>   # This is called with 2 arguments: the XMLNode object (containing
>   # its children) and the list of attributes.
>   # We get the variable name via call to xmlValue().
> 
>   # Note that we define the closure function in the call and then 
>   # create an instance of it by calling it directly as
>   #   (function() {...})()
> 
>   # Note that we can get the names by parsing
>   # in the usual manner and the entire document and then executing
>   # xmlSApply(xmlRoot(doc)[[1]], function(x) xmlValue(x[[1]]))
>   # which is simpler but is more costly in terms of memory.
>  fileName <- system.file("exampleData", "mtcars.xml", package="XML")
>  doc <- xmlTreeParse(fileName,  handlers = (function() { 
+                                  vars <- character(0) ;
+                                 list(variable=function(x, attrs) { 
+                                                 vars <<- c(vars, xmlValue(x[[1]])); 
+                                                 NULL}, 
+                                      startElement=function(x,attr){
+                                                    NULL
+                                                   }, 
+                                      names = function() {
+                                                  vars
+                                              }
+                                     )
+                                })()
+                      )
> 
>   # Here we just print the variable names to the console
>   # with a special handler.
>  doc <- xmlTreeParse(fileName, handlers = list(
+                                   variable=function(x, attrs) {
+                                              print(xmlValue(x[[1]])); TRUE
+                                            }), asTree=TRUE)
[1] "mpg"
[1] "cyl"
[1] "disp"
[1] "hp"
[1] "drat"
[1] "wt"
[1] "qsec"
[1] "vs"
[1] "am"
[1] "gear"
[1] "carb"
> 
> 
>   # This should raise an error.
>   try(xmlTreeParse(
+             system.file("exampleData", "TestInvalid.xml", package="XML"),
+             validate=TRUE))

 *** caught segfault ***
address 0xfe3c, cause 'memory not mapped'

Traceback:
 1: xmlTreeParse(system.file("exampleData", "TestInvalid.xml", package = "XML"),     validate = TRUE)
 2: doTryCatch(return(expr), name, parentenv, handler)
 3: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 4: tryCatchList(expr, classes, parentenv, handlers)
 5: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call, nlines = 1L)        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        sm <- strsplit(conditionMessage(e), "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
 6: try(xmlTreeParse(system.file("exampleData", "TestInvalid.xml",     package = "XML"), validate = TRUE))
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault