public void Initialize(XPathDocument doc, IXmlLineInfo lineInfo, string baseUri, XPathDocument.LoadFlags flags) { XPathNode[] nodeArray; this.doc = doc; this.nameTable = doc.NameTable; this.atomizeNames = (flags & XPathDocument.LoadFlags.AtomizeNames) != XPathDocument.LoadFlags.None; this.idxParent = this.idxSibling = 0; this.elemNameIndex = new XPathNodeRef[0x40]; this.textBldr.Initialize(lineInfo); this.lineInfo = lineInfo; this.lineNumBase = 0; this.linePosBase = 0; this.infoTable = new XPathNodeInfoTable(); int idxText = this.NewNode(out nodeArray, XPathNodeType.Text, string.Empty, string.Empty, string.Empty, string.Empty); this.doc.SetCollapsedTextNode(nodeArray, idxText); this.idxNmsp = this.NewNamespaceNode(out this.pageNmsp, this.nameTable.Add("xml"), this.nameTable.Add("http://www.w3.org/XML/1998/namespace"), null, 0); this.doc.SetXmlNamespaceNode(this.pageNmsp, this.idxNmsp); if ((flags & XPathDocument.LoadFlags.Fragment) == XPathDocument.LoadFlags.None) { this.idxParent = this.NewNode(out this.pageParent, XPathNodeType.Root, string.Empty, string.Empty, string.Empty, baseUri); this.doc.SetRootNode(this.pageParent, this.idxParent); } else { this.doc.SetRootNode(this.nodePageFact.NextNodePage, this.nodePageFact.NextNodeIndex); } }
public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { this.idxSimilar = (ushort)idxSimilar; if (pageSimilar != this.info.SimilarElementPage) { this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, this.info.SiblingPage, pageSimilar, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }
/// <summary> /// Link this element to the next element in document order that shares a local name having the same hash code. /// If "pageSimilar" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { Debug.Assert(pageSimilar != null && idxSimilar != 0 && idxSimilar <= ushort.MaxValue, "Bad argument"); Debug.Assert(_idxSimilar == 0, "SetSimilarElement should not be called more than once."); _idxSimilar = (ushort)idxSimilar; if (pageSimilar != _info.SimilarElementPage) { // Re-atomize the InfoAtom _info = infoTable.Create(_info.LocalName, _info.NamespaceUri, _info.Prefix, _info.BaseUri, _info.ParentPage, _info.SiblingPage, pageSimilar, _info.Document, _info.LineNumberBase, _info.LinePositionBase); } }
/// <summary> /// Link this node to its next sibling. If "pageSibling" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSibling(XPathNodeInfoTable infoTable, XPathNode[] pageSibling, int idxSibling) { Debug.Assert(pageSibling != null && idxSibling != 0 && idxSibling <= UInt16.MaxValue, "Bad argument"); Debug.Assert(this.idxSibling == 0, "SetSibling should not be called more than once."); this.idxSibling = (ushort)idxSibling; if (pageSibling != this.info.SiblingPage) { // Re-atomize the InfoAtom this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, pageSibling, this.info.SimilarElementPage, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }
/// <summary> /// Start construction of a new document. This must be called before any other methods are called. /// It may also be called after Close(), in order to build further documents. /// </summary> public void Initialize(XPathDocument doc, IXmlLineInfo lineInfo, string baseUri, XPathDocument.LoadFlags flags) { XPathNode[] page; int idx; _doc = doc; _nameTable = doc.NameTable; _atomizeNames = (flags & XPathDocument.LoadFlags.AtomizeNames) != 0; _idxParent = _idxSibling = 0; _elemNameIndex = new XPathNodeRef[ElementIndexSize]; // Prepare line number information _textBldr.Initialize(lineInfo); _lineInfo = lineInfo; _lineNumBase = 0; _linePosBase = 0; // Allocate the atomization table _infoTable = new XPathNodeInfoTable(); // Allocate singleton collapsed text node idx = NewNode(out page, XPathNodeType.Text, string.Empty, string.Empty, string.Empty, string.Empty); _doc.SetCollapsedTextNode(page, idx); // Allocate xmlns:xml namespace node _idxNmsp = NewNamespaceNode(out _pageNmsp, _nameTable.Add("xml"), _nameTable.Add(XmlConst.ReservedNsXml), null, 0); _doc.SetXmlNamespaceNode(_pageNmsp, _idxNmsp); if ((flags & XPathDocument.LoadFlags.Fragment) == 0) { // This tree has a document root node _idxParent = NewNode(out _pageParent, XPathNodeType.Root, string.Empty, string.Empty, string.Empty, baseUri); _doc.SetRootNode(_pageParent, _idxParent); } else { // This tree is an XQuery fragment (no document root node), so root will be next node in the current page _doc.SetRootNode(_nodePageFact.NextNodePage, _nodePageFact.NextNodeIndex); } }
/// <summary> /// Link this element to the next element in document order that shares a local name having the same hash code. /// If "pageSimilar" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { Debug.Assert(pageSimilar != null && idxSimilar != 0 && idxSimilar <= UInt16.MaxValue, "Bad argument"); Debug.Assert(this.idxSimilar == 0, "SetSimilarElement should not be called more than once."); this.idxSimilar = (ushort)idxSimilar; if (pageSimilar != this.info.SimilarElementPage) { // Re-atomize the InfoAtom this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, this.info.SiblingPage, pageSimilar, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }
/// <summary> /// Start construction of a new document. This must be called before any other methods are called. /// It may also be called after Close(), in order to build further documents. /// </summary> public void Initialize(XPathDocument doc, IXmlLineInfo lineInfo, string baseUri, XPathDocument.LoadFlags flags) { XPathNode[] page; int idx; _doc = doc; _nameTable = doc.NameTable; _atomizeNames = (flags & XPathDocument.LoadFlags.AtomizeNames) != 0; _idxParent = _idxSibling = 0; _elemNameIndex = new XPathNodeRef[ElementIndexSize]; // Prepare line number information _textBldr.Initialize(lineInfo); _lineInfo = lineInfo; _lineNumBase = 0; _linePosBase = 0; // Allocate the atomization table _infoTable = new XPathNodeInfoTable(); // Allocate singleton collapsed text node idx = NewNode(out page, XPathNodeType.Text, string.Empty, string.Empty, string.Empty, string.Empty); _doc.SetCollapsedTextNode(page, idx); // Allocate xmlns:xml namespace node _idxNmsp = NewNamespaceNode(out _pageNmsp, _nameTable.Add("xml"), _nameTable.Add(XmlReservedNs.NsXml), null, 0); _doc.SetXmlNamespaceNode(_pageNmsp, _idxNmsp); if ((flags & XPathDocument.LoadFlags.Fragment) == 0) { // This tree has a document root node _idxParent = NewNode(out _pageParent, XPathNodeType.Root, string.Empty, string.Empty, string.Empty, baseUri); _doc.SetRootNode(_pageParent, _idxParent); } else { // This tree is an XQuery fragment (no document root node), so root will be next node in the current page _doc.SetRootNode(_nodePageFact.NextNodePage, _nodePageFact.NextNodeIndex); } }
/// <summary> /// Link this node to its next sibling. If "pageSibling" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSibling(XPathNodeInfoTable infoTable, XPathNode[] pageSibling, int idxSibling) { Debug.Assert(pageSibling != null && idxSibling != 0 && idxSibling <= UInt16.MaxValue, "Bad argument"); Debug.Assert(_idxSibling == 0, "SetSibling should not be called more than once."); _idxSibling = (ushort)idxSibling; if (pageSibling != _info.SiblingPage) { // Re-atomize the InfoAtom _info = infoTable.Create(_info.LocalName, _info.NamespaceUri, _info.Prefix, _info.BaseUri, _info.ParentPage, pageSibling, _info.SimilarElementPage, _info.Document, _info.LineNumberBase, _info.LinePositionBase); } }
public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { this.idxSimilar = (ushort) idxSimilar; if (pageSimilar != this.info.SimilarElementPage) { this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, this.info.SiblingPage, pageSimilar, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }