Mica::XML::Document
A parsed XML document.
Nodes live in an arena owned by the document: fixed-size records in
pages plus a chunked heap for names' values and text. Mica::XML::Node is a
small struct (document + index) pointing into it, so a large document
costs a few allocations instead of one object per node, and the garbage
collector never scans node records (they hold no pointers).
A document answers the Mica::XML::Node API for its document node:
document = Mica::XML.parse(%(<feed><title>News</title></feed>))
document.root.try(&.name) # => "feed"
document.xpath_string("string(//title)") # => "News"
Constants
The default budget for edits: the same rate as parsing, without a deadline (edits are calls the application makes one at a time).
Constructors
Instance methods
Sets the edit budget. The next edit starts a fresh meter on it.
Returns the meter that edits through Node (setting, renaming and
removing attributes, names and content) are charged to. Its units are
the document's nodes, name bytes and value bytes when it starts, plus
one per edit
call and the bytes each call is given (names, values, text), so the
work of any sequence of edits stays linear in the document and the
edits' input; a sequence that would do more stops with a
Mica::WorkBudgetExceededError. Created on the first edit.
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
True when the document was parsed with Namespaces in XML enforced
(ParserOptions#namespace_aware). Edits follow the same rules.
Returns the operations the parse that built this document charged (reading and building together).
Replaces the edit meter with a fresh one for budget, for documents that are edited in rounds over a long life.
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>