File: xmlEventHandler.R

package info (click to toggle)
r-cran-xml 3.99-0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,688 kB
  • sloc: ansic: 6,659; xml: 2,890; asm: 486; sh: 12; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (10)
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
xmlEventHandler <- 
function() {
  con <- xmlOutputDOM()

  startElement <- function(name, atts,...) {
    con$addTag(name, attrs=atts, close=FALSE)
  }
  endElement <- function(name) {
    con$closeTag(name)
  }
  text <- function(x,...) {
    con$addNode(xmlTextNode(x))  
  }
  comment <- function(x,...) {
    xmlCommentNode(x)
  }
  externalEntity <- function(ctxt, baseURI, sysId, publicId,...) {
    cat("externalEntity", ctxt, baseURI, sysId, publicId,"\n")
  }
  entityDeclaration <- function(name, baseURI, sysId, publicId, notation, ...) {
    # just writing to screen at this point.
    cat("externalEntity", name, baseURI, sysId, publicId, notation,"\n")
  }

 processingInstruction <- function(sys, value) {
   con$addNode(xmlPINode(sys, value))
 }

 list(startElement=startElement, endElement=endElement,
      processingInstruction=processingInstruction,
      text=text,
      comment=comment,
      externalEntity=externalEntity,
      entityDeclaration=entityDeclaration,
      dom=function(){con})
}