Skip to main content

Module xml

Module xml 

Source

Structs§

ParsedFragment
A parsed markup chunk, bundled with the throwaway document that owns it.
XPath

Constants§

XMLNS_NS
XML_NS

Functions§

closest_element
compiled_xpath
xpath compiled, from compiled or compiled now; None when it does not compile (its string evaluation then reports it as before — compiling it a second time, so libxml2’s stderr line prints twice: PERFORMANCE.md P10) or compiled is full.
content_nodes
obtains all content children of node (Element and Text), ignoring all other node types
descendant_or_self_elements
The elements of root’s subtree, root included, that keep accepts, in document order: the walk behind a whole-document descendant-or-self::*[pred], which libxml2 2.15 answers through a node set over every element and refuses past 10,000,000 of them (“XPath evaluation failure”, #802).
detached_root
Walk node’s ancestor chain to the top. If the chain ends at a Document (or document-fragment) node the subtree is LIVE — part of a document tree — and None is returned; otherwise the topmost node is a DETACHED root and is returned. Callers use this to decide whether a source tree they are done with is theirs to free (Document::discard_subtree) or still reachable from a live document.
element_nodes
obtains all Element children of node, ignoring all other node types
get_next_element
gets the following Element sibling of node (skipping over non-element nodes)
get_prev_element
gets the previous Element sibling of node (skipping over non-element nodes)
is_descendant_or_self
Is child the same as parent, or a descendent of parent?
is_ltx_element
XPath’s ltx:<local> name test: a LaTeXML-namespace element named local. Unlike get_node_qname, it rejects a namespace-less element of that name, as the XPath it replaces does.
is_parse_artifact
Is node an artifact of HOW a chunk was parsed, rather than part of the chunk? True for exactly the two things that can sit ABOVE a chunk’s top-level nodes: the throwaway parse_fragment wrapper, and the parsed document node.
name_is
node.get_name() == name, read without an owned String (MEM1 L12).
parse_chunk
Parse a standalone markup string into its own document — the port of Perl LaTeXML::Common::XML::Parser::parseChunk (Common/XML/Parser.pm:36-39: parse_string($string) then ->documentElement, “expects only a single node”). Parsing lives here, beside the rest of the Common::XML helpers, and NOT in Document — mirroring Perl, where Document::appendTree only ever consumes already-parsed nodes.
parse_fragment
Parse a markup chunk that may be a document FRAGMENT — several sibling nodes, or bare text — and return its owning document together with the top-level nodes to insert. Returning the two together is deliberate: libxml Nodes are handles into the document that owns them, so the caller must keep the [Document] alive for exactly as long as it uses the nodes.