class

KXML::Document

Inherits KXML::Node < Reference < Object

Instance methods

allocate_order(node : Node | Attribute) : Int32

Monotonic document order for mutation-created nodes. Structural mutations can place a new node before existing ones, so a plain "max + 1" would hand out orders that contradict document order; the whole document is renumbered in traversal order instead.

Source
allocate_order_after(node : Node | Attribute, pred : Node | Attribute, prev_last : Node | Attribute) : Int32

Fast path for the common "append at the end" mutation: when pred (the node the new node follows in document order) was the document's last node before the insertion - prev_last, snapshotted by the caller before it spliced the node in - the new node simply takes the next orders instead of paying the full-tree renumber pass. Any other position falls back to renumber.

Source
children
Source
create_element(name : String, context : Element | Nil = nil, prefix_hint : String | Nil = nil) : Element

Creates an element for name (a Clark-notation {uri}local or a plain/qualified name). When a namespace URI is involved and no in-scope binding exists on context (or its ancestors), the binding is declared on the new element itself using prefix_hint (or a generated nsN) - mirroring libxml2's xmlSearchNsByHref/xmlNewNs dance.

Source
create_text(content : String) : Text
Source
deepest_last

The node holding the maximum doc_order. Order stays monotonic with document position across mutations: every insertion either renumbers or appends after the current maximum, and unlink only removes nodes (the relative order of the survivors is untouched).

Source
deepest_last_of(start : Node | Attribute) : Node | Attribute

Deepest, last node of start's subtree in document order: attributes order between their element and its children, and the last child's subtree precedes anything after it.

Source
doctype
Source
doctype=(doctype : DocumentType | Nil)
Source
id_attribute_names

Attribute names declared ID in the internal DTD subset (population is best-effort: only ATTLIST declarations seen during the parse register here). Lets XPath's id() resolve tokens.

Source
mark_orders_dirty
Source
misc_after
Source
misc_before
Source
orders_dirty?
Source
renumber

Assigns doc_order to every node and attribute in document order (pre-order traversal, attributes immediately after their element).

Source
root
Source
root=(root : Element | Nil)
Source
to_xml(io : IO, pretty : Bool, indent_size : Int32 = 2) : Nil

pretty mirrors libxml2's XML::SaveOptions::FORMAT: elements whose children are all elements/comments/PIs get one child per line with indent_size-space indentation; text-bearing content is inline.

Source
to_xml(io : IO) : Nil
Source
to_xml(pretty : Bool, indent_size : Int32 = 2) : String
Source