PhoenixmlDb.Core

XmlDocumentParser

Parses XML content (strings, streams, or readers) into an XDM node tree.

#XmlDocumentParser

Namespace: PhoenixmlDb.Xdm.Parsing

Parses XML content (strings, streams, or readers) into an XDM node tree.

This is the primary mechanism for converting XML text into the in-memory XDM representation used throughout PhoenixmlDb. The parser produces a containing the root node and a flat list of all nodes in document order. Node ID assignment: Each node receives a unique starting from startNodeId and incrementing monotonically. The document node receives the first ID, followed by elements, attributes, text nodes, etc., in document order. This sequential assignment enables efficient storage and retrieval. Namespace interning: Namespace URIs are converted to values via the provided namespaceResolver function. This deduplicates namespace strings across the entire database, making namespace comparisons an integer operation. Usage: This parser is used internally by PutDocumentAsync when storing documents, but is also available for direct use when you need to parse XML without storing it.

#Constructors

##ctor(PhoenixmlDb.Core.DocumentId,PhoenixmlDb.Core.NodeId,Func<String,PhoenixmlDb.Core.NamespaceId>,Boolean)

Creates a new XML parser that will assign the specified document and node IDs.

Parameters:

  • documentId — The to assign to all parsed nodes.

  • startNodeId — The first to assign. Subsequent nodes receive incrementing IDs.

  • namespaceResolver — Function that converts namespace URI strings to interned values. This is typically backed by a database-wide namespace table.

  • preserveWhitespace — When true, whitespace-only text nodes are preserved. When false (default), they are discarded, matching the behavior of strip-space in XSLT.

#Methods

#AddNode(PhoenixmlDb.Xdm.Nodes.XdmNode)

Appends a node to the flat node list and the id index in lockstep. All node creation must route through here so stays in sync.

#CreateTextNode(String,Nullable<PhoenixmlDb.Core.NodeId>,Int32,Int32)

Creates a single text node from an already-coalesced run of character data. The caller supplies the concatenated and the source position of the FIRST character-data event in the run (see the coalescing loop in ). The value is always non-empty by construction.

#Parse(IO.Stream,String)

Parses XML content from a into an XDM document tree.

Parameters:

  • stream — A stream containing the XML content. The stream's encoding is auto-detected.

  • documentUri — Optional document URI to assign to the resulting .

Returns: A containing the document and all parsed nodes.

Exceptions:

  • XmlException — The XML content is not well-formed.

#Parse(IO.TextReader,String,Xml.Schema.XmlSchemaSet)

Parses XML content with XSD schema validation, populating type annotations (including xs:ID / xs:IDREF) from the schema.

Parameters:

  • textReader — A reader positioned at the start of the XML content.

  • documentUri — Optional document URI to assign to the resulting .

  • schemas — The XSD schema set to validate against.

Returns: A containing the document and all parsed nodes.

#Parse(IO.TextReader,String)

Parses XML content from a into an XDM document tree.

Parameters:

  • textReader — A reader positioned at the start of the XML content.

  • documentUri — Optional document URI to assign to the resulting .

Returns: A containing the document and all parsed nodes.

Exceptions:

  • XmlException — The XML content is not well-formed.

#Parse(String,String)

Parses XML content from a string into an XDM document tree.

Parameters:

  • xml — The XML content to parse. Must be well-formed XML.

  • documentUri — Optional document URI to assign to the resulting .

Returns: A containing the document and all parsed nodes.

Exceptions:

  • XmlException — The XML content is not well-formed.

#ResolveSchemaTypeAnnotation(Xml.XmlQualifiedName,PhoenixmlDb.Xdm.XdmTypeName)

Computes the string value of an element from its children (text + nested elements). Walks _nodes to resolve child NodeIds. Maps an from the XmlReader's SchemaInfo to an suitable for or . Returns when no schema type was reported, when the type is anonymous (no QualifiedName), or when the qualified name has no local part.

#Fields

Name Description
_readerSchemaTypeProperties Cached reflection accessors for the internal SchemaType property on validating readers. This property returns an for DTD-validated attributes, exposing the needed to identify ID/IDREF/IDREFS attributes. We cache per-reader-type because different validation modes use different internal reader types (XmlValidatingReaderImpl for DTD, XsdValidatingReader for XSD). Using a single cached PropertyInfo across both fails at runtime when types mismatch.