The XML_TREE signature defines a tree representation of XML files.
Synopsis
signature XML_TREE
Interface
structure Schema : XML_SCHEMA
datatype doctype = DOCTYPE of string * external_id option
and external_id
= SYSTEM of string
| PUBLIC of string * string
datatype content
= TEXT of string
| CDATA of string
| ELEMENT of {
name : Schema.element,
attrs : Schema.attribute list,
content : content list
}
type tree = {
xmlDecl : Schema.attribute list option,
doctype : doctype option,
content : content
}
Description
structure Schema : XML_SCHEMA-
This substructure defines the representation of elements and attributes.
datatype doctype = DOCTYPE of string * external_id option-
This datatype represents the contents of the optional
DOCTYPEelement found the beginning of the file (following the optional XML declaration). We currently only support external DTDs. datatype external_id-
This datatype represents an external DTD specification; its constructors are defined as follows:
SYSTEM of url-
specifies a "private" external DTD, where the string
urlspecifies the DTD’s location. PUBLIC(name, url)-
specifies a "public" external DTD, where the string
nameis the name of the DTD andurlspecifies the DTD’s location.
datatype content-
This datatype is used to represent the content of an XML file as a tree. The constructors have the following meanings:
TEXT s-
represents the text described by the string
s. When parsing, entities in the source (e.g.,<) are replaced by their definition and, when printing, special characters (e.g.,<) are replaced by their entities. CDATA s-
represents the literal text described by the string
s. ELEMENT{name, attrs, content}-
represents a subtree enclosed by "`<element>` …
</element>" tags, where `nameis the name of the element,attrsis a list of attributes in the start tag, andcontentis the stuff between the tags.
type tree-
An XML tree, which is a record type with the following fields:
xmlDecl : Schema.attribute list option-
This field represents the optional XML declaration at the beginning of a file, where a value of
SOME attrsmeans that there was an XML declaration present with the list of attributesattrs. doctype : doctype option-
This field represents the optional
DOCTYPEelement that follows the XML declaration. content : content-
This field is the root of the content and will always be an
ELEMENT.