https://github.com/cran/XML
Raw File
Tip revision: 3c0b64398bf79b865a4134380b14356c1683f77f authored by Duncan Temple Lang on 31 May 2015, 00:00:00 UTC
version 3.98-1.2
Tip revision: 3c0b643
tags.Sxml
<?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>
back to top