PhoenixmlDb.Core

XdmElement

Represents an XML element node in the XDM tree, including its attributes, children, and namespace declarations.

#XdmElement

Namespace: PhoenixmlDb.Xdm.Nodes

Represents an XML element node in the XDM tree, including its attributes, children, and namespace declarations.

Children: An element's children are stored as a list of NodeId references in XdmElement.Children. Valid child node kinds are element, text, comment, and processing instruction. To access the actual child nodes, resolve each NodeId through the storage layer's node lookup function.

Attributes: Attributes are separate XdmAttribute nodes referenced by XdmElement.Attributes. Per the XDM spec, attributes are not children of the element — they exist on a separate axis. Use the attribute list to enumerate or look up attributes by name.

Namespaces: Each element carries its own XdmElement.NamespaceDeclarations, which record the namespace declarations (xmlns:prefix="uri") that appear on this element. The element's own namespace is stored separately in XdmElement.Namespace.

Construction: Elements are typically created by XmlDocumentParser during XML parsing, or constructed directly using object initializers with the required properties. Use XdmElement.EmptyAttributes, XdmElement.EmptyChildren, and XdmElement.EmptyNamespaceDeclarations for elements that have no attributes, children, or namespace declarations.

#Example

Constructing an element programmatically:

csharp
var element = new XdmElement
{
    Id = nodeId,
    Document = documentId,
    Namespace = NamespaceId.None,
    LocalName = "item",
    Prefix = null,
    Attributes = XdmElement.EmptyAttributes,
    Children = XdmElement.EmptyChildren,
    NamespaceDeclarations = XdmElement.EmptyNamespaceDeclarations
};
                                  

#Properties

Name Description
Attributes The NodeId references to this element's XdmAttribute nodes.
Children The NodeId references to this element's child nodes (elements, text, comments, and processing instructions) in document order.
EmptyAttributes An empty, immutable attribute list for elements with no attributes.
EmptyChildren An empty, immutable children list for leaf elements (no child nodes).
EmptyNamespaceDeclarations An empty, immutable namespace declarations list for elements with no namespace declarations.
IsIdContent True if this element's simple-content type is xs:ID or a type derived from xs:ID by restriction. Populated during XSD schema validation. Used by fn:id and fn:element-with-id to locate elements whose typed content matches a candidate ID.
LocalName The element's local name (the part after the colon in a prefixed name).
Namespace The element's namespace URI, stored as an interned NamespaceId.
NamespaceDeclarations The namespace declarations (xmlns:prefix="uri") that appear on this element.
Prefix The namespace prefix used in the original document, preserved for round-trip serialization.
StringValue The string value of this element, which is the concatenation of all descendant text nodes.
TypeAnnotation The XSD type annotation for this element (default: xs:untyped).

#Fields

Name Description
_stringValue Internal backing field for the lazily-computed string value. Set by tree walkers after traversing descendant text nodes.