/usr/lib/R/site-library/XML/examples/oop.S is in r-cran-xml 3.98-1.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | k <- defineClass("LiterateXMLHandler")
k$defineFields(chunks = "list")
k$defineMethod("startElement", function(node) {
id <- xmlGetAttr(node, "id")
if(!is.null(id))
chunks[[id]] <<- node
node
})
k$defineMethod("chunk", function(node) {
if(is.null(name <- xmlGetAttr(node, "name")))
stop("Chunk with no name")
if(is.na(match(name, names(chunks))))
stop("No chunk defined named", name,". Is it a forward chunk reference?")
nnode <- chunks[[name]]
if(xmlName(nnode) == "code")
code(nnode, FALSE)
})
k$defineMethod("code", function(node, checkId = TRUE) {
if(checkId)
startElement(node)
node
})
oopXMLHandlers <-
function(obj)
{
startElement <-
function(node) {
m <- findOOPMethod(OOPClassDef(obj), xmlName(node), mustFind = FALSE)
if(is.null(m)) {
m <- findOOPMethod(OOPClassDef(obj), "startElement", mustFind = FALSE)
name <- "startElement"
} else
name <- xmlName(node)
if(!is.null(m)) {
m <- completeForObject(obj, name, FALSE)
m(node)
} else
node
}
list(startElement = startElement, value = function() obj)
}
|