1<?xml version="1.0"?>
2<!DOCTYPE SSource SYSTEM
3"/home/duncan/Projects/org/omegahat/XML/RS/examples/SSource.dtd"
4[
5  <!ENTITY TeX "TeX">
6  <!ENTITY sgets "<-">
7]>
8<SSource>
9
10  <overview>
11  This file defines some S functions for computing information about
12an XML tree. We start by defining a recursive function that computes
13the list of unique tags within a document.  This is useful for
14defining translations from these tags to another format, e.g. &TeX;.
15This identifies the names of the tags that one has to map to the TeX
16macros or environments.
17  </overview>
18
19  <function>
20    <sname>xmlTags</sname>
21    <selfDoc>
22     <aliases></aliases>
23     <description>
24     </description>
25    </selfDoc>
26    <def>
27      function(node, exclude=c("XMLEntityRef")) {
28        if(inherits(node, exclude)) {
29          return(character(0))
30        }
31
32
33        if(xmlSize(node) > 0) {
34         which &sgets; xmlSApply(node, function(x, excludes)
35                                          !inherits(x, excludes),
36                                 excludes = exclude)
37         vals &sgets; names(node)[which]
38         vals &sgets; unique(c(vals,
39                               unlist(sapply(xmlChildren(node)[which], xmlTags, exclude ))))
40        } else
41           vals &sgets; character(0)
42       vals
43      }
44    </def>
45  </function>
46
47</SSource>
48