Statifier.Parser.DOM.Element (Statifier v2.0.0)

Copy Markdown View Source

A generic XML element: a name, an ordered attribute list, an ordered child list, and the source span it occupies.

Nothing here knows what any name means. The element is whatever the XML said - no validation, no namespace resolution - and giving it meaning is the lowering pass's job (docs/architecture.md, "Parser: DOM first, then lowering"). Nothing on the element itself is normalized either; the one normalization the parser does perform is XML 1.0 3.3.3 on attribute values, which an XML processor owes its application before a value exists at all (ADR-0043) - see Statifier.Parser.DOM.Attribute.

  • name is the raw qualified name exactly as it appeared, prefix included.
  • attributes are in document order, with duplicates preserved: a document that declares the same attribute twice is a thing the validator gets to report, so the parser may not silently drop one of them.
  • children are in document order and interleave elements with Statifier.Parser.DOM.Text, so mixed markup is representable. Whitespace-only text is a child like any other; Statifier.Parser.DOM.elements/1 is the filter for readers that do not want it.
  • location spans from the < of the start tag to the byte after the > of the end tag (for a self-closing element, the tag itself).

Summary

Types

child()

@type child() :: t() | Statifier.Parser.DOM.Text.t()

t()

@type t() :: %Statifier.Parser.DOM.Element{
  attributes: [Statifier.Parser.DOM.Attribute.t()],
  children: [child()],
  location: Statifier.Parser.Location.t(),
  name: binary()
}