#[repr(u32)]pub enum NodeKind {
Element = 1,
Attribute = 2,
Text = 3,
CData = 4,
EntityRef = 5,
Comment = 8,
Pi = 7,
Document = 9,
DocumentFragment = 11,
Dtd = 14,
DtdDecl = 15,
}Expand description
Discriminant for Node::kind.
#[repr(u32)] chosen to match libxml2’s xmlElementType numeric layout —
the future extern "C" shim can transmute / cast directly. Variant values
are pinned to libxml2’s enum order; do not reorder without a coordinated
ABI update.
Variants§
Element = 1
<element>...</element>.
Attribute = 2
An attribute. Only used as the kind of an
Attribute under the c-abi feature
— never appears on a real Node; the libxml2 ABI requires
xmlAttr’s type field at offset 8 to carry this discriminant
so generic walkers casting xmlAttr* to xmlNode* see the
right type.
Text = 3
Character data between tags. content holds the (entity-expanded) text.
CData = 4
<![CDATA[…]]>. Preserved as a distinct kind for round-trip serialization.
EntityRef = 5
An unresolved entity reference — &name; left literal in the
tree. Emitted only when the parser is configured with
resolve_entities: false; the default expands entity
references inline. name holds the entity name (e.g.
"foo" for &foo;); content holds the literal source
form "&foo;" so serialization round-trips by writing
content verbatim, and lxml-compat code can return
node.text == "&foo;".
libxml2’s enum value for XML_ENTITY_REF_NODE is 5 —
pinned here so generic walkers see the right tag.
Comment = 8
<!-- … -->.
Pi = 7
<?target content?>.
Document = 9
The document root. Only used as the kind of an
XmlDoc under the c-abi feature — never
appears on a real Node. libxml2’s enum value for
XML_DOCUMENT_NODE is 9.
DocumentFragment = 11
A detached subtree root with no semantic content of its own —
just a parent for an ordered list of child nodes. Returned by
xmlNewDocFragment and used by callers that want to build a
composite subtree before grafting it into a real document.
libxml2’s enum value for XML_DOCUMENT_FRAG_NODE is 11.
Dtd = 14
The DOCTYPE internal-subset node itself (XML_DTD_NODE = 14).
Never allocated in the arena — sup-xml models the DTD through
the compat shim’s 128-byte xmlDtd struct, which shares the
node header (kind@8, children@24, parent@40, next@48,
prev@56, doc@64) with Node. The shim splices that
struct into the document’s sibling chain at the DOCTYPE’s true
position; reinterpreted as a Node it reports this kind, so
every tree walker traverses past it as an inert node (it emits
no markup of its own — lxml serializes the subset via
doc->intSubset directly).
DtdDecl = 15
A document-type internal-subset declaration block (<!ENTITY …>,
<!ELEMENT …>, <!ATTLIST …>, …). Held as the single child of
the internal-subset DTD node; content carries the raw markup
declarations (each terminated by a newline) verbatim, which the
serializer emits unescaped inside the DOCTYPE’s [ … ]. The
discriminant sits in libxml2’s declaration-type range
(XML_ELEMENT_DECL = 15) so generic walkers treat it as a DTD
declaration; sup-xml does not model per-declaration nodes.