The SML of NJ Library
The `XML_TREE` signature

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 `DOCTYPE` element 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 `url` specifies the DTD’s location.

  `PUBLIC(name, url)`

    specifies a "public" external DTD, where the string `name` is the name of the DTD and `url` specifies 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 `name` is the name of the element, `attrs` is a list of attributes in the start tag, and `content` is 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 attrs` means that there was an XML declaration present with the list of attributes `attrs`.

  `doctype : doctype option`

    This field represents the optional `DOCTYPE` element that follows the XML declaration.

  `content : content`

    This field is the root of the content and will always be an `ELEMENT`.

## See Also

`XML_SCHEMA`, `XMLTreeFn`, The XML Library

SML/NJ Version 110.99.3 (August 1, 2023)
Last updated 2023-07-31 17:59:01 UTC