PhoenixmlDb.Core

XdmNode

Abstract base class for all XDM (XPath Data Model) nodes, representing the in-memory structure of XML and JSON documents as defined by the W3C XDM specification.

#XdmNode

Namespace: PhoenixmlDb.Xdm.Nodes

Abstract base class for all XDM (XPath Data Model) nodes, representing the in-memory structure of XML and JSON documents as defined by the W3C XDM specification.

The XDM defines seven node kinds: XdmNodeKind.Document, XdmNodeKind.Element, XdmNodeKind.Attribute, XdmNodeKind.Text, XdmNodeKind.Comment, XdmNodeKind.ProcessingInstruction, and XdmNodeKind.Namespace. Each is represented by a concrete subclass of XdmNode.

Navigation: Every node except the document root has a XdmNode.Parent property pointing to its containing node. To access children or attributes, cast the node to XdmElement or XdmDocument and use their child/attribute lists. Children and attributes are referenced by NodeId, which must be resolved through a node lookup function (e.g., the one provided by the storage layer).

Values: XdmNode.StringValue returns the text content of the node as defined by the XDM dm:string-value accessor. For element and document nodes, this is the concatenation of all descendant text nodes. XdmNode.TypedValue returns the schema-typed value (dm:typed-value), which is xs:untypedAtomic for unvalidated content.

Identity: The XdmNode.Id property is a storage-assigned identifier used for efficient node lookup and parent/child references. It is not related to the xml:id attribute or the XDM dm:is identity function.

#Example

Checking a node's kind and accessing its value:

csharp
XdmNode node = ...;
if (node.IsElement)
{
    var element = (XdmElement)node;
    Console.WriteLine($"Element: {element.NodeName}");
    Console.WriteLine($"Text content: {element.StringValue}");
}
                                  

#Properties

Name Description
BaseUri The base URI for this node (dm:base-uri), used for resolving relative URIs.
CopySourceBaseUri Base URI inherited from the source element during xsl:copy operations.
Document The identifier of the document that contains this node.
DocumentOrderKey The value key that totally orders and identifies this node in XDM document order: the pair (TreeOrdinal, Id).
Id Unique storage identifier for this node, assigned during parsing or construction.
IsAttribute Returns true if this node is an XdmAttribute node.
IsComment Returns true if this node is an XdmComment node.
IsDocument Returns true if this node is a XdmDocument node.
IsElement Returns true if this node is an XdmElement node.
IsNamespace Returns true if this node is an XdmNamespace node.
IsProcessingInstruction Returns true if this node is an XdmProcessingInstruction node.
IsText Returns true if this node is an XdmText node.
NodeKind The kind of this node (element, attribute, text, etc.).
NodeName The qualified name of this node (dm:node-name), or null for node kinds that have no name (text, comment, document).
Parent The parent node's identifier, or null for document nodes (which have no parent).
SourceColumn Column number where this node starts in its source document, 1-based. Zero means "no source position" (synthesized node).
SourceLine Line number where this node starts in its source document, 1-based. Zero means "no source position" (synthesized node).
StrictStringValue When enabled, reading XdmNode.StringValue on an element or document that has NEITHER a computed value NOR a XdmNode.StringValueResolver throws instead of returning the empty string. Off by default.
StringValue The string value of this node, as defined by the XDM dm:string-value accessor.
StringValueResolver Supplies XdmNode.StringValue on first read for a node whose value could not be computed when it was constructed. Required for element and document nodes reconstructed from storage, whose children are resolved lazily and so cannot be walked at build time.
TreeOrdinal Store-global monotonic ordinal identifying the tree (parsed document or constructed subtree) this node belongs to, used as the primary key of XDM document order.
TypedValue The typed value of this node, as defined by the XDM dm:typed-value accessor.

#Methods

#CompareDocumentOrder(PhoenixmlDb.Xdm.Nodes.XdmNode,PhoenixmlDb.Xdm.Nodes.XdmNode)

Compares two nodes in XDM document order using the pair

(TreeOrdinal, Id)

.

Parameters:

  • a — The first node.

  • b — The second node.

Returns: A negative value if a precedes b, a positive value if it follows, and zero if they occupy the same position (same tree and same node id).

This is a total order:

is compared first (grouping nodes by their originating tree via a store-global counter), then

orders nodes within a tree. It is the single canonical comparison for all document-order sort, union, intersect, except, and

<<

/

>>

sites.

#Is(PhoenixmlDb.Core.XdmNodeKind)

Returns

true

if this node has the specified

.

Parameters:

  • kind — The node kind to test against.

#ToString

Returns

, providing the XDM string value of this node.

#UnresolvedStringValue(PhoenixmlDb.Xdm.Nodes.XdmNode)

Produces the value an element or document reports when it has no computed string value and no resolver: the empty string, or an exception under

.

Parameters:

  • node — The node being read, named in the exception message.

#Fields

Name Description
StrictStringValueSwitchName The name of the AppContext switch backing XdmNode.StrictStringValue.