PhoenixmlDb.XQuery
XdmDocumentStore
An in-memory XDM document store that manages parsed XML documents, node resolution, and namespace interning. Implements both and so it can be passed directly to .
#XdmDocumentStore
Namespace: PhoenixmlDb.XQuery
An in-memory XDM document store that manages parsed XML documents, node resolution, and namespace interning. Implements both and so it can be passed directly to .
This is the recommended way to set up standalone XQuery execution against in-memory XML. Load documents via or , then pass this store as both the nodeProvider and documentResolver to .
#Properties
| Name | Description |
|---|---|
Documents
|
All loaded documents. |
HasRegisteredCollections
|
Whether any collections have been explicitly registered via . |
XInclude
|
When set (non-null with true), documents loaded by this store have their xi:include elements expanded before XDM conversion. Off by default. Only affects freshly parsed text (file/string/stream) β not documents already registered as XDM. |
#Methods
#AllocateNodeId
Allocates a new unique for constructed nodes (e.g., XQuery element/text constructors).
Returns: A fresh node ID that does not collide with any existing node.
#ConstructionEpoch
Returns this store's construction epoch, allocating it on first use. All constructed nodes in the store share this single ordinal (tie-broken by ), and its high bit places it above every parse-time ordinal.
#ExpandXInclude(Xml.XmlReader,String,PhoenixmlDb.Core.Xml.XIncludeOptions)
Loads into an intermediate DOM, expands its xi:includes against the absolute , and returns the serialized result for re-parsing into XDM. The reader is encoding-aware (it honors the document's XML declaration / BOM), unlike pre-decoding a stream with a bare StreamReader. DTD handling matches the normal load path (): internal entities expand, external DTD/entities are not fetched (no XXE).
#GetNode(PhoenixmlDb.Core.NodeId)
#IsDocumentAvailable(String)
#LoadFile(String)
Loads an XML document from a file path.
Parameters:
-
filePathβ The path to the XML file.
Returns: The parsed XDM document node.
#LoadFromStream(IO.Stream,String)
Loads an XML document from a stream.
Parameters:
-
streamβ The stream containing XML content. -
documentUriβ Optional URI that identifies this document.
Returns: The parsed XDM document node.
#LoadFromString(String,String)
Loads an XML document from a string.
Parameters:
-
xmlβ The XML content to parse. -
documentUriβ Optional URI that identifies this document. When set, the document can be retrieved via fn:doc() using this URI.
Returns: The parsed XDM document node.
#LoadFromStringWithSchema(String,String,Xml.Schema.XmlSchemaSet)
Loads an XML document from a string with XSD schema validation. Schema type annotations (xs:ID, xs:IDREF, etc.) are populated from the schema.
Parameters:
-
xmlβ The XML content to parse. -
documentUriβ Optional URI that identifies this document. -
schemasβ The XSD schema set to validate against.
Returns: The parsed XDM document node.
#MaybeExpandXInclude(String,String)
When is enabled, expands xi:include elements in (resolved against the absolute ) before it is handed to . Returns unchanged when XInclude is off.
#RegisterCollection(String,Collections.Generic.List<Object>)
Registers a named collection of items (nodes or atomic values).
Parameters:
-
uriβ The collection URI. Use empty string for the default collection. -
itemsβ The items in the collection.
#RegisterNamespace(String,PhoenixmlDb.Core.NamespaceId)
Registers a specific for a URI, so that elements constructed with IDs from the static analyzer can be serialized back to their namespace URIs. If the URI is already registered, this is a no-op (the existing ID is kept).
#RegisterNode(PhoenixmlDb.Xdm.Nodes.XdmNode)
Registers a constructed node (created by XQuery node constructors) in the store, making it resolvable via .
Parameters:
-
nodeβ The node to register.
Stamps the node with this store's construction epoch (issue #188) so it participates in cross-store document order and sorts after any parsed document. Nodes that already carry a (parse-time or copied) ordinal are left untouched.
#RegisterParsedNodes(Collections.Generic.IEnumerable<PhoenixmlDb.Xdm.Nodes.XdmNode>)
Stamps a batch of freshly-parsed nodes with a single, store-global parse-time tree ordinal (issue #188) and registers them. All nodes of one loaded document share the ordinal, so intra-document order is decided by exactly as before; documents loaded later receive higher ordinals, preserving multi-document order within the store.
#ResolveCollection(String)
#ResolveDocument(String)
#ResolveNamespace(String)
Resolves a namespace URI string to an interned .
Parameters:
-
namespaceUriβ The namespace URI to intern.
Returns: The interned namespace identifier.
#ResolveNamespaceUri(PhoenixmlDb.Core.NamespaceId)
Resolves an interned back to its URI string. Used by for XML serialization.
Parameters:
-
idβ The namespace identifier.
Returns: The namespace URI, or null if the identifier is not known.
#ToLocalPath(String)
Converts a file:// URI to a local file path. Returns the original string for non-file URIs.
#TryResolveCollectionItems(String,Collections.Generic.List<Object>@)
Tries to resolve a collection by URI, returning the items if found. Supports both node and non-node (atomic value) collections per XQuery 3.1.
Parameters:
-
uriβ The collection URI, or null / empty string for the default collection. -
itemsβ The resolved items, or null if the collection is not found.
Returns: true if the collection was found; false otherwise.
#Fields
| Name | Description |
|---|---|
_collections
|
Registered named collections. Key is the collection URI (empty string for default collection). Values are the items in the collection (may be nodes or atomic values per XQuery 3.1). |
_constructionTreeOrdinal
|
This store's construction epoch (issue #188): the single tree ordinal stamped onto every node constructed in this store (element/text/PI constructors, parse-xml, json-to-xml). Allocated lazily on the first so it exceeds the ordinals of all documents loaded before construction began β constructed nodes therefore sort last, and constructed nodes of two independent stores stay grouped by store. Zero until first use. |
_hasRegisteredCollections
|
Whether any collections have been explicitly registered. When true, returns empty for unknown URIs instead of falling back to all-documents or single-document resolution. |