On this page:
Document
Document.prolog
Document.element
Document.misc
Element
Element.name
Element.attributes
Element.content
Element.srcloc
Attribute
Attribute.name
Attribute.value
Attribute.srcloc
Content
Text
Text.text
Text.srcloc
Text.write_  mode
Text.Write  Mode
Text.Write  Mode.default
Text.Write  Mode.cdata
Text.Write  Mode.entity
Entity
Entity.text
Entity.srcloc
Entity  Int
Inject
Inject.text
Inject.srcloc
Comment
Comment.text
Processing  Instruction
Processing  Instruction.target_  name
Processing  Instruction.instruction
Processing  Instruction.srcloc
Misc
Other  Permitted
current_  permissive
Prolog
Prolog.post_  misc
Prolog.dtd
Prolog.pst_  misc
DTD
DTD.name
DTD.system
DTD.public
Srcloc  Range
Srcloc  Range.start
Srcloc  Range.end
8.17.0.3

1 XML Document Representation🔗ℹ

class

class xml.Document(~prolog: prolog :: xml.Prolog = xml.Prolog(),

                   ~element: element :: xml.Element,

                   ~misc: misc :: List.of(xml.Misc) = [])

Represents an XML document, which always contains a single element. A document optionally contains a document-type descriptor in the prolog, and it may have miscellaneous comments and processing instructions after the element.

class

class xml.Element(~name: name :: String,

                  ~attributes: attributes :: List.of(xml.Attribute) = [],

                  ~content: content :: List.of(xml.Content) = [],

                  ~srcloc: srcloc :: maybe(xml.SrclocRange) = #false)

 

class

class xml.Attribute(~name: name :: String,

                    ~value: value :: String || xml.OtherPermitted,

                    ~srcloc: srcloc :: maybe(xml.SrclocRange) = #false)

 

annotation

xml.Content

An xml.Element represents an XML term of them form <tag></tag>, where name field corresponds to tag, attributes correspond to attributes within <tag>, and content is the content between <tag> and </tag>.

The xml.Content annotation recognizes allowed content values:

class

class xml.Text(~text: text :: String,

               ~srcloc: srcloc :: maybe(xml.SrclocRange) = #false,

               ~write_mode: write_mode :: xml.Text.WriteMode = #'default)

 

enumeration

enum xml.Text.WriteMode:

  default

  cdata

  entity

Represents text for the content of an xml.Element.

The write_mode field is used by xml.write to select an encoding of the text:

class

class xml.Entity(~text: text :: String || xml.EntityInt,

                 ~srcloc: srcloc :: maybe(xml.SrclocRange) = #false)

 

annotation

xml.EntityInt

Represents entities written with &; as the content of an xml.Element.

Reading with normalization (see xml.current_read_normalize) produces this form only for symbolic entities, and reading always uses xml.Text instead for the predefined entities &amp;, &lt;, &gt;, &apos;, and &quot;.

class

class xml.Inject(~text: text :: String,

                 ~srcloc: srcloc :: maybe(xml.SrclocRange) = #false)

Represents text as the content of an xml.Element that is written verbatim by xml.write. The text might not conform to XML syntax. A xml.read never produces this form of content.

class

class xml.Comment(~text: text :: String)

 

class

class xml.ProcessingInstruction(

  ~target_name: target_name :: String,

  ~instruction: instruction :: String,

  ~srcloc: srcloc :: maybe(xml.SrclocRange) = #false

)

 

annotation

xml.Misc

The xml.Misc annotation recognizes xml.Comment and xml.ProcessingInstruction instances. These values can appear with an xml.Element as content, or they can appear before or after the element of a xml.Document.

xml.Comment represents comment written with <!---->. Comments are discarded by xml.read unless xml.current_read_comments is #true.

xml.ProcessingInstruction represents a processing instruction written with <??>. Comments are discarded by xml.read unless xml.current_read_processing_instructions is #true.

annotation

xml.OtherPermitted

 

context parameter

Parameter.def xml.current_permissive :: Any.to_boolean:

  #false

When xml.current_permissive is set to #true, then xml.Element content and xml.Attribute values can be anything. Such values can be converted to and from XML syntax objects, but not read or written as XML.

class

class xml.Prolog(~pre_misc: post_misc :: List.of(xml.Misc) = [],

                 ~dtd: dtd :: maybe(xml.DTD) = #false,

                 ~post_misc: pst_misc :: List.of(xml.Misc) = [])

 

class

class xml.DTD(~name: name :: String,

              ~system: system :: String,

              ~public: public :: maybe(String) = #false)

Represents metadata for an XML document.

Represents the source location of an element, attribute, or content in an XML document. The start source location has a Srcloc.span value to capture the difference between the start and end source locations for an XML component, but end provides additional information about the ending line and column.