File: tags.Sxml

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 (47 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download | duplicates (7)
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
<?xml version="1.0"?>
<!DOCTYPE SSource SYSTEM
"/home/duncan/Projects/org/omegahat/XML/RS/examples/SSource.dtd"
[ 
  <!ENTITY TeX "TeX">
  <!ENTITY sgets "<-">
]>
<SSource>

  <overview>
  This file defines some S functions for computing information about
an XML tree. We start by defining a recursive function that computes
the list of unique tags within a document.  This is useful for
defining translations from these tags to another format, e.g. &TeX;.
This identifies the names of the tags that one has to map to the TeX
macros or environments.
  </overview>

  <function>
    <sname>xmlTags</sname>
    <selfDoc>
     <aliases></aliases>
     <description>
     </description>
    </selfDoc>
    <def>
      function(node, exclude=c("XMLEntityRef")) {
        if(inherits(node, exclude)) {
          return(character(0))
        }


        if(xmlSize(node) > 0) {
         which &sgets; xmlSApply(node, function(x, excludes)
                                          !inherits(x, excludes), 
                                 excludes = exclude)
         vals &sgets; names(node)[which] 
         vals &sgets; unique(c(vals,
                               unlist(sapply(xmlChildren(node)[which], xmlTags, exclude ))))
        } else
           vals &sgets; character(0)
       vals
      }
    </def>
  </function>

</SSource>