<?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>
