dtdElement.RdA DTD in R consists of both element and entity definitions. These two functions provide simple access to individual elements of these two lists, using the name of the element or entity. The DTD is provided to determine where to look for the entry.
dtdElement(name,dtd)
dtdEntity(name,dtd)An element within a DTD contains
both the list of sub-elements it can contain and a list of attributes
that can be used within this tag type.
dtdElement retrieves the
element by name from the specified DTD definition.
Entities within a DTD are like macros or text substitutes used
within a DTD and/or XML documents that use it.
Each consists of a name/label and a definition, the text
that is substituted when the entity is referenced.
dtdEntity retrieves the entity definition
from the DTD.
\
One can read a DTD
directly (using parseDTD) or implicitly when reading a
document (using xmlTreeParse)
The names of all available elements can be obtained from the expression
names(dtd$elements).
This function is simply a convenience for
indexing this elements list.
An object of class XMLElementDef.
dtdFile <- system.file("exampleData","foo.dtd", package="XML")
foo.dtd <- parseDTD(dtdFile)
# Get the definition of the `entry1' element
tmp <- dtdElement("variable", foo.dtd)
xmlAttrs(tmp)
#> $type
#> $name
#> [1] "type"
#>
#> $type
#> CDATA
#> 16
#>
#> $defaultType
#> Implied
#> 3
#>
#> $defaultValue
#> [1] ""
#>
#> attr(,"class")
#> [1] "XMLAttributeDef"
#>
#> $unit
#> $name
#> [1] "unit"
#>
#> $type
#> CDATA
#> 16
#>
#> $defaultType
#> Implied
#> 3
#>
#> $defaultValue
#> [1] ""
#>
#> attr(,"class")
#> [1] "XMLAttributeDef"
#>
#> $levels
#> $name
#> [1] "levels"
#>
#> $type
#> CDATA
#> 16
#>
#> $defaultType
#> Implied
#> 3
#>
#> $defaultValue
#> [1] ""
#>
#> attr(,"class")
#> [1] "XMLAttributeDef"
#>
tmp <- dtdElement("entry1", foo.dtd)
# Get the definition of the `img' entity
dtdEntity("img", foo.dtd)
#> NULL