Documentation
¶
Overview ¶
Package xml provides a bounded, deterministic XML fragment CRDT.
A fragment is an ordered RGA of immutable XML nodes. Editing a node means inserting a replacement and deleting the old node; this deliberately avoids pretending that concurrent attribute writes have a proven merge rule. Node insertions, deletions, duplicate delivery, and out-of-order delivery use the generic list RGA protocol and remain convergent.
Index ¶
- Variables
- func MarshalDelta(delta Delta) ([]byte, error)
- func RenderDocument(node Node) (string, error)
- type Attribute
- type Delta
- type Fragment
- func (f *Fragment) Append(nodes []Node) (Delta, error)
- func (f *Fragment) ApplyDelta(delta Delta) error
- func (f *Fragment) Delete(offset, count int) (Delta, error)
- func (f *Fragment) Insert(offset int, nodes []Node) (Delta, error)
- func (f *Fragment) MarshalBinary() ([]byte, error)
- func (f *Fragment) Merge(other *Fragment) error
- func (f *Fragment) Nodes() ([]Node, error)
- func (f *Fragment) Positions() []Position
- func (f *Fragment) RenderFragment() (string, error)
- func (f *Fragment) SnapshotCurrentState() (snapshot.Snapshot, error)
- func (f *Fragment) State() crdt.StateSnapshot
- func (f *Fragment) UnmarshalBinary(data []byte) error
- type Node
- type NodeKind
- type Position
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func MarshalDelta ¶
MarshalDelta returns a canonical fragment delta frame.
func RenderDocument ¶
RenderDocument returns one deterministic XML document. node must be an element because XML documents cannot have text as their root.
Types ¶
type Attribute ¶
Attribute is one element attribute. Attribute names are ASCII XML names, unique within a node, and stored in canonical lexical order.
type Delta ¶
Delta is a joinable fragment mutation.
func UnmarshalDelta ¶
UnmarshalDelta validates one bounded canonical fragment delta frame.
type Fragment ¶
type Fragment struct {
// contains filtered or unexported fields
}
Fragment is an ordered, collaboratively replicated XML fragment.
func NewFromSnapshot ¶
NewFromSnapshot restores a complete fragment snapshot with default limits.
func NewFromSnapshotWithOptions ¶
NewFromSnapshotWithOptions restores a complete fragment snapshot within explicit list retention and decoder limits.
func NewWithOptions ¶
NewWithOptions creates a fragment with explicit retained-state limits.
func (*Fragment) ApplyDelta ¶
ApplyDelta integrates one decoded fragment mutation.
func (*Fragment) MarshalBinary ¶
MarshalBinary encodes a canonical complete fragment state frame.
func (*Fragment) RenderFragment ¶
RenderFragment returns the concatenated XML rendering of visible top-level nodes. A fragment containing multiple elements is intentionally not a full XML document; use RenderDocument for one document root.
func (*Fragment) SnapshotCurrentState ¶
SnapshotCurrentState creates an HLC-backed complete fragment snapshot.
func (*Fragment) State ¶
func (f *Fragment) State() crdt.StateSnapshot
State returns a value-free diagnostic summary.
func (*Fragment) UnmarshalBinary ¶
UnmarshalBinary validates a complete framed state before replacing f.
type Node ¶
Node is an immutable-by-convention XML value. Insert copies its canonical representation, and Values returns newly decoded values, so callers can safely mutate their own slices after either call.
Namespace prefixes, DTDs, comments, processing instructions, and mixed non-text token classes are intentionally unsupported in v1. Text and child nodes may be mixed inside an element.
func ParseDocument ¶
ParseDocument parses one strict, bounded XML document into a node. It rejects directives, comments, processing instructions, namespaces, and extra top-level content so every accepted result has one deterministic v1 representation.