Document Representations
This guide explains the differences between the XML document representations available in .NET and XmlPrime.
This topic contains the following sections.
Overview
XmlPrime operates on XPathNavigatorXPathNavigatorXPathNavigator instances for node values. There are a number of XML document representations available in .NET implementing IXPathNavigableIXPathNavigableIXPathNavigable, all of which have different strengths and weaknesses. Whilst all these document representations are compatible with XmlPrime, there are different performance and conformance issues with the different representations. For these reasons, we recommend using an XdmDocumentXdmDocumentXdmDocument, whenever possible for use with XmlPrime, which is a new document representation designed to comply with the XQuery 1.0 and XPath 2.0 Data Model (XDM) specification.
This article outlines the differences between the document representations.
Limitations of the XmlReader
The XmlReaderXmlReaderXmlReader class does not publicly expose the full XML Information Set (InfoSet), and in particular does not publicly report the (DTD) type of attributes. It does not provide any way of examining the external DTDs used by a document. For these reasons it is impossible to determine which nodes are XML IDs and IDREFs if the document uses an external DTD, and it is not possible to identify if this is the case.
Therefore, when loading from an XML reader, the XdmDocumentXdmDocumentXdmDocument is unable to identify ID and IDREF nodes which have been identified by an external DTD.
System.Xml.XmlDocument
The XmlDocumentXmlDocumentXmlDocument is modelled on the Document Object Model (DOM) Level 1 and Document Object Model (DOM) Level 2 Core. It is an editable document format. However it is not optimized for querying so is not recommended for use with XmlPrime.
System.Xml.XPath.XPathDocument
The XPathDocumentXPathDocumentXPathDocument is modelled on the XPath 1.0 Data Model (XDM). It is designed for high performance read-only use.
System.Xml.Linq.XDocument
Whilst XDocumentXDocumentXDocument does not implement IXPathNavigableIXPathNavigableIXPathNavigable, an XPathNavigatorXPathNavigatorXPathNavigator instance can be created with the CreateNavigatorCreateNavigatorCreateNavigator method. The XDocument is an editable document designed to support LINQ. However it is not optimized for querying, so is not recommended for use with XmlPrime.
XmlPrime.XdmDocument
The XdmDocumentXdmDocumentXdmDocument is modelled on the XQuery 1.0 and XPath 2.0 Data Model (XDM) and is designed for high performance read-only use. It is similar to XPathDocumentXPathDocumentXPathDocument, but also preserves schema information. It is recommended to use this document format for documents passed to XmlPrime.