Last updated on 2025-08-21 15:50:38 CEST.
Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
---|---|---|---|---|---|---|
r-devel-linux-x86_64-debian-clang | 3.99-0.18 | 22.34 | 78.26 | 100.60 | NOTE | |
r-devel-linux-x86_64-debian-gcc | 3.99-0.18 | 17.74 | 51.47 | 69.21 | ERROR | |
r-devel-linux-x86_64-fedora-clang | 3.99-0.18 | 161.80 | WARN | |||
r-devel-linux-x86_64-fedora-gcc | 3.99-0.18 | 166.35 | WARN | |||
r-devel-windows-x86_64 | 3.99-0.18 | 45.00 | 140.00 | 185.00 | WARN | |
r-patched-linux-x86_64 | 3.99-0.18 | 25.66 | 73.72 | 99.38 | ERROR | |
r-release-linux-x86_64 | 3.99-0.18 | 27.66 | 72.55 | 100.21 | NOTE | |
r-release-macos-arm64 | 3.99-0.18 | 51.00 | NOTE | |||
r-release-macos-x86_64 | 3.99-0.18 | 153.00 | NOTE | |||
r-release-windows-x86_64 | 3.99-0.18 | 40.00 | 135.00 | 175.00 | WARN | |
r-oldrel-macos-arm64 | 3.99-0.18 | 47.00 | OK | |||
r-oldrel-macos-x86_64 | 3.99-0.18 | 133.00 | OK | |||
r-oldrel-windows-x86_64 | 3.99-0.18 | 44.00 | 118.00 | 162.00 | WARN |
Version: 3.99-0.18
Check: compiled code
Result: NOTE
File ‘XML/libs/XML.so’:
Found non-API call to R: ‘OBJECT’
Compiled code should not call non-API entry points in R.
See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual,
and section ‘Moving into C API compliance’ for issues with the use of
non-API entry points.
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-patched-linux-x86_64, r-release-linux-x86_64, r-release-macos-arm64, r-release-macos-x86_64
Version: 3.99-0.18
Check: whether package can be installed
Result: WARN
Found the following significant warnings:
DocParse.c:67:2: warning: ‘__xmlDoValidityCheckingDefaultValue’ is deprecated [-Wdeprecated-declarations]
DocParse.c:70:6: warning: ‘__xmlDoValidityCheckingDefaultValue’ is deprecated [-Wdeprecated-declarations]
HTMLParse.c:143:5: warning: ‘use’ is deprecated [-Wdeprecated-declarations]
HTMLParse.c:152:9: warning: ‘content’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:121:3: warning: ‘validate’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:134:7: warning: ‘xmlSkipBlankChars’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:135:7: warning: ‘xmlParseMarkupDecl’ is deprecated [-Wdeprecated-declarations]
RUtils.c:142:5: warning: ‘xmlSubstituteEntitiesDefault’ is deprecated [-Wdeprecated-declarations]
XMLTree.c:1439:5: warning: ‘use’ is deprecated [-Wdeprecated-declarations]
XMLTree.c:1442:9: warning: ‘content’ is deprecated [-Wdeprecated-declarations]
XMLTree.c:1444:9: warning: ‘content’ is deprecated [-Wdeprecated-declarations]
See ‘/home/hornik/tmp/R.check/r-devel-gcc/Work/PKGS/XML.Rcheck/00install.out’ for details.
* used C compiler: ‘gcc-15 (Debian 15.2.0-1) 15.2.0’
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 3.99-0.18
Check: examples
Result: ERROR
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-devel-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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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"
>
> # parse the document, discarding comments.
>
> xmlTreeParse(fileName, handlers=list("comment"=function(x,...){NULL}), asTree = TRUE)
$doc
$file
[1] "/home/hornik/tmp/R.check/r-devel-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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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"
>
>
> # 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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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"
>
>
> # 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 0xfe38, 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
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 3.99-0.18
Check: whether package can be installed
Result: WARN
Found the following significant warnings:
DocParse.c:67:25: warning: '__xmlDoValidityCheckingDefaultValue' is deprecated [-Wdeprecated-declarations]
DocParse.c:70:6: warning: '__xmlDoValidityCheckingDefaultValue' is deprecated [-Wdeprecated-declarations]
RSDTD.c:134:7: warning: 'xmlSkipBlankChars' is deprecated [-Wdeprecated-declarations]
RSDTD.c:135:7: warning: 'xmlParseMarkupDecl' is deprecated [-Wdeprecated-declarations]
RUtils.c:142:13: warning: 'xmlSubstituteEntitiesDefault' is deprecated [-Wdeprecated-declarations]
See ‘/data/gannet/ripley/R/packages/tests-clang/XML.Rcheck/00install.out’ for details.
* used C compiler: ‘clang version 21.1.0-rc3’
Flavor: r-devel-linux-x86_64-fedora-clang
Version: 3.99-0.18
Check: whether package can be installed
Result: WARN
Found the following significant warnings:
DocParse.c:67:2: warning: ‘__xmlDoValidityCheckingDefaultValue’ is deprecated [-Wdeprecated-declarations]
DocParse.c:70:6: warning: ‘__xmlDoValidityCheckingDefaultValue’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:134:7: warning: ‘xmlSkipBlankChars’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:135:7: warning: ‘xmlParseMarkupDecl’ is deprecated [-Wdeprecated-declarations]
RUtils.c:142:5: warning: ‘xmlSubstituteEntitiesDefault’ is deprecated [-Wdeprecated-declarations]
See ‘/data/gannet/ripley/R/packages/tests-devel/XML.Rcheck/00install.out’ for details.
* used C compiler: ‘gcc (GCC) 15.1.1 20250521 (Red Hat 15.1.1-2)’
Flavor: r-devel-linux-x86_64-fedora-gcc
Version: 3.99-0.18
Check: whether package can be installed
Result: WARN
Found the following significant warnings:
RSDTD.c:134:7: warning: 'xmlSkipBlankChars' is deprecated [-Wdeprecated-declarations]
RSDTD.c:135:7: warning: 'xmlParseMarkupDecl' is deprecated [-Wdeprecated-declarations]
RUtils.c:142:5: warning: 'xmlSubstituteEntitiesDefault' is deprecated [-Wdeprecated-declarations]
See 'd:/Rcompile/CRANpkg/local/4.6/XML.Rcheck/00install.out' for details.
* used C compiler: 'gcc.exe (GCC) 14.2.0'
Flavor: r-devel-windows-x86_64
Version: 3.99-0.18
Check: compiled code
Result: NOTE
File 'XML/libs/x64/XML.dll':
Found non-API call to R: 'OBJECT'
Compiled code should not call non-API entry points in R.
See 'Writing portable packages' in the 'Writing R Extensions' manual,
and section 'Moving into C API compliance' for issues with the use of
non-API entry points.
Flavors: r-devel-windows-x86_64, r-release-windows-x86_64
Version: 3.99-0.18
Check: whether package can be installed
Result: WARN
Found the following significant warnings:
DocParse.c:67:2: warning: ‘__xmlDoValidityCheckingDefaultValue’ is deprecated [-Wdeprecated-declarations]
DocParse.c:70:6: warning: ‘__xmlDoValidityCheckingDefaultValue’ is deprecated [-Wdeprecated-declarations]
HTMLParse.c:143:5: warning: ‘use’ is deprecated [-Wdeprecated-declarations]
HTMLParse.c:152:9: warning: ‘content’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:121:3: warning: ‘validate’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:134:7: warning: ‘xmlSkipBlankChars’ is deprecated [-Wdeprecated-declarations]
RSDTD.c:135:7: warning: ‘xmlParseMarkupDecl’ is deprecated [-Wdeprecated-declarations]
RUtils.c:142:5: warning: ‘xmlSubstituteEntitiesDefault’ is deprecated [-Wdeprecated-declarations]
XMLTree.c:1439:5: warning: ‘use’ is deprecated [-Wdeprecated-declarations]
XMLTree.c:1442:9: warning: ‘content’ is deprecated [-Wdeprecated-declarations]
XMLTree.c:1444:9: warning: ‘content’ is deprecated [-Wdeprecated-declarations]
See ‘/home/hornik/tmp/R.check/r-patched-gcc/Work/PKGS/XML.Rcheck/00install.out’ for details.
* used C compiler: ‘gcc-14 (Debian 14.2.0-19) 14.2.0’
Flavor: r-patched-linux-x86_64
Version: 3.99-0.18
Check: examples
Result: ERROR
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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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("test.xml", replaceEntities = TRUE)</code>
works, but
<code>xmlTreeParse("test.xml")</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
Flavor: r-patched-linux-x86_64
Version: 3.99-0.18
Check: whether package can be installed
Result: WARN
Found the following significant warnings:
RSDTD.c:134:7: warning: 'xmlSkipBlankChars' is deprecated [-Wdeprecated-declarations]
RSDTD.c:135:7: warning: 'xmlParseMarkupDecl' is deprecated [-Wdeprecated-declarations]
RUtils.c:142:5: warning: 'xmlSubstituteEntitiesDefault' is deprecated [-Wdeprecated-declarations]
See 'd:/Rcompile/CRANpkg/local/4.5/XML.Rcheck/00install.out' for details.
* used C compiler: 'gcc.exe (GCC) 14.2.0'
Flavor: r-release-windows-x86_64
Version: 3.99-0.18
Check: whether package can be installed
Result: WARN
Found the following significant warnings:
RSDTD.c:134:7: warning: 'xmlSkipBlankChars' is deprecated [-Wdeprecated-declarations]
RSDTD.c:135:7: warning: 'xmlParseMarkupDecl' is deprecated [-Wdeprecated-declarations]
RUtils.c:142:5: warning: 'xmlSubstituteEntitiesDefault' is deprecated [-Wdeprecated-declarations]
See 'd:/Rcompile/CRANpkg/local/4.4/XML.Rcheck/00install.out' for details.
* used C compiler: 'gcc.exe (GCC) 13.3.0'
Flavor: r-oldrel-windows-x86_64
Version: 3.99-0.18
Check: installed package size
Result: NOTE
installed size is 5.2Mb
sub-directories of 1Mb or more:
exampleData 1.3Mb
libs 2.2Mb
Flavor: r-oldrel-windows-x86_64