private void StartLine(StringBuilder sb, XPathNode tree, int level = 0) { if (changed - level >= 0) { if (!first_time) { for (int j = 0; j < level; ++j) { sb.Append(" "); } for (int k = 0; k < 1 + changed - level; ++k) { sb.Append(") "); } sb.AppendLine(); } changed = 0; first_time = false; } changed = level; for (int j = 0; j < level; ++j) { sb.Append(" "); } }
/// <include file='doc\XPathDocumentView.uex' path='docs/doc[@for="XPathDocumentView.XPathDocumentView1"]/*' /> public XPathDocumentView(XPathDocument document, IXmlNamespaceResolver namespaceResolver) { if (null == document) { throw new ArgumentNullException(nameof(document)); } this.document = document; this.ndRoot = document.Root; if (null == this.ndRoot) { throw new ArgumentException(nameof(document)); } this.namespaceResolver = namespaceResolver; ArrayList rows = new ArrayList(); this.rows = rows; Debug.Assert(XPathNodeType.Root == this.ndRoot.NodeType); XPathNode nd = this.ndRoot.Child; while (null != nd) { if (XPathNodeType.Element == nd.NodeType) { rows.Add(nd); } nd = nd.Sibling; } DeriveShapeFromRows(); }
public void ParenthesizedAST(XPathNode tree, StringBuilder sb, int level = 0) { if (tree == null) { return; } { var fixed_name = tree.GetType().ToString(); var ind = fixed_name.LastIndexOf('.'); fixed_name = fixed_name.Substring(ind + 1); StartLine(sb, tree, level); sb.Append("( " + fixed_name); sb.Append(" " + tree.QuickInfo()); sb.AppendLine(); } foreach (var c in tree.GetAllChildren()) { ParenthesizedAST(c, sb, level + 1); } if (level == 0) { for (int k = 0; k < 1 + changed - level; ++k) { sb.Append(") "); } sb.AppendLine(); changed = 0; } }
/// <summary> /// Return chain of in-scope namespace nodes for nodes of type Element. Nodes in the chain might not /// have this element as their parent. Since the xmlns:xml namespace node is always in scope, this /// method will never return 0 if the specified node is an element. /// </summary> public static int GetInScopeNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp) { XPathDocument doc; // Only elements have namespace nodes if (pageElem[idxElem].NodeType == XPathNodeType.Element) { doc = pageElem[idxElem].Document; // Walk ancestors, looking for an ancestor that has at least one namespace declaration while (!pageElem[idxElem].HasNamespaceDecls) { idxElem = pageElem[idxElem].GetParent(out pageElem); if (idxElem == 0) { // There are no namespace nodes declared on ancestors, so return xmlns:xml node return doc.GetXmlNamespaceNode(out pageNmsp); } } // Return chain of in-scope namespace nodes return doc.LookupNamespaces(pageElem, idxElem, out pageNmsp); } pageNmsp = null; return 0; }
public override object GetValue(object o) { if (null == o) { throw new ArgumentNullException("XPathNodeViewPropertyDescriptor.GetValue"); } XPathNodeView xiv = (XPathNodeView)o; if (xiv.Collection.RowShape != this.rowShape) { throw new ArgumentException("XPathNodeViewPropertyDescriptor.GetValue"); } object val = xiv.Column(this.colIndex); XPathNode nd = val as XPathNode; if (null != nd) { XPathDocumentNavigator nav = new XPathDocumentNavigator(nd, null); XmlSchemaType xst = nd.SchemaType; XmlSchemaComplexType xsct = xst as XmlSchemaComplexType; if (null == xst || ((null != xsct) && xsct.IsMixed)) { return(nav.InnerXml); } else { return(nav.TypedValue); } } return(val); }
public XPathDocumentNavigator(XPathNode[] pageCurrent, int idxCurrent, XPathNode[] pageParent, int idxParent) { this.pageCurrent = pageCurrent; this.pageParent = pageParent; this.idxCurrent = idxCurrent; this.idxParent = idxParent; }
//----------------------------------------------- // Constructors //----------------------------------------------- /// <summary> /// Create a new navigator positioned on the specified current node. If the current node is a namespace or a collapsed /// text node, then the parent is a virtualized parent (may be different than .Parent on the current node). /// </summary> public XPathDocumentNavigator(XPathNode[] pageCurrent, int idxCurrent, XPathNode[] pageParent, int idxParent) { Debug.Assert(pageCurrent != null && idxCurrent != 0); Debug.Assert((pageParent == null) == (idxParent == 0)); this.pageCurrent = pageCurrent; this.pageParent = pageParent; this.idxCurrent = idxCurrent; this.idxParent = idxParent; }
protected IXmlCursor Cursor(XPathNavigator parent, string pathText, CursorFlags flags) { var parentNode = new XPathNode(parent, typeof(object), NamespaceSource.Instance); var compiledPath = XPathCompiler.Compile(pathText); compiledPath.SetContext(Context); return(Cursor(parentNode, compiledPath, IncludedTypes, flags)); }
private static LinkedList <XPathNode> ReconstructPath(XPathNode currentNode) { LinkedList <XPathNode> result = new LinkedList <XPathNode>(); ReconstructPathRecursive(currentNode, result); return(result); }
protected virtual double CalculateHeuristicFast(XPathNode inStart, XPathNode inEnd) { double dx1 = inStart.X - _endNode.X; double dy1 = inStart.Y - _endNode.Y; double cross = Math.Abs(dx1 - dy1); return(Math.Ceiling(Math.Abs(inStart.X - inEnd.X) + (double)Math.Abs(inStart.Y - inEnd.Y)) + cross); }
// // XPath support // void InitFromXPath(XPathNode ndRoot, string xpath) { XPathStep[] steps = ParseXPath(xpath, this.xpathResolver); ArrayList rows = this.rows; rows.Clear(); PopulateFromXPath(ndRoot, steps, 0); DeriveShapeFromRows(); }
/// <summary> /// Return chain of namespace nodes. If specified node has no local namespaces, then 0 will be /// returned. Otherwise, the first node in the chain is guaranteed to be a local namespace (its /// parent is this node). Subsequent nodes may not have the same node as parent, so the caller will /// need to test the parent in order to terminate a search that processes only local namespaces. /// </summary> public static int GetLocalNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp) { if (pageElem[idxElem].HasNamespaceDecls) { // Only elements have namespace nodes Debug.Assert(pageElem[idxElem].NodeType == XPathNodeType.Element); return pageElem[idxElem].Document.LookupNamespaces(pageElem, idxElem, out pageNmsp); } pageNmsp = null; return 0; }
public void MoveTo_NotARecognizedNode_Fails() { var xml = Xml("<X/>"); var cursor = Cursor(xml, "A", CursorFlags.Multiple); var wrongNode = new XPathNode(Xml("<Q/>"), typeof(object), NamespaceSource.Instance); Assert.Throws <InvalidOperationException>(() => cursor.MoveTo(wrongNode)); }
public StringBuilder OutputTree(XPathNode tree) { var sb = new StringBuilder(); changed = 0; first_time = true; ParenthesizedAST(tree, sb, 0); return(sb); }
// // IXPathNavigable Implementation public XPathNavigator CreateNavigator() { XPathNode nd = this.rowNd; if (null != nd) { return(new XPathDocumentNavigator(this.rowNd, null)); } return(null); }
private void ResetSearchSpace() { for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { _mSearchSpace[y, x] = new XPathNode(x, y, SearchSpace); } } }
/// <summary> /// Return the first attribute of the specified node. If no attribute exist, do not /// set pageNode or idxNode and return false. /// </summary> public static bool GetFirstAttribute(ref XPathNode[] pageNode, ref int idxNode) { Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); if (pageNode[idxNode].HasAttribute) { GetChild(ref pageNode, ref idxNode); Debug.Assert(pageNode[idxNode].NodeType == XPathNodeType.Attribute); return true; } return false; }
/// <summary> /// Check the XPath node. /// </summary> /// <param name="node"> /// is the XPath node to check. </param> /// <exception cref="StaticError"> /// static error. </exception> public virtual void check(XPathNode node) { try { node.accept(this); } catch (DummyError) { throw _err; } }
private void Advance() { XPathNode nd = this.node; int errorCode; this.currentParticle = this.contentValidator.ValidateElement(new XmlQualifiedName(nd.LocalName, nd.NamespaceUri), this.currentState, out errorCode); if (null == this.currentParticle || 0 != errorCode) { this.node = null; } }
private ICollection normalize_bin_args(BinExpr e) { var args = new ArrayList(); XPathNode left = (XPathNode)e.left().accept(this); XPathNode right = (XPathNode)e.right().accept(this); args.Add(left); args.Add(right); return(args); }
/// <summary> /// Return the next attribute sibling of the specified node. If the node is not itself an /// attribute, or if there are no siblings, then do not set pageNode or idxNode and return false. /// </summary> public static bool GetNextAttribute(ref XPathNode[] pageNode, ref int idxNode) { XPathNode[] page; int idx; Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); idx = pageNode[idxNode].GetSibling(out page); if (idx != 0 && page[idx].NodeType == XPathNodeType.Attribute) { pageNode = page; idxNode = idx; return true; } return false; }
public bool Next() { if (null != this.node) { this.node = TreeNavigationHelper.GetContentSibling(this.node, XPathNodeType.Element); if (node != null) { Advance(); } return(null != this.node); } return(false); }
XPathNodeView FillRow(XPathNode ndRow, Shape shape) { object[] columns; XPathNode nd; switch (shape.BindingType) { case BindingType.Text: case BindingType.Attribute: columns = new object[1]; columns[0] = ndRow; return(new XPathNodeView(this, ndRow, columns)); case BindingType.Repeat: columns = new object[1]; nd = TreeNavigationHelper.GetContentChild(ndRow); columns[0] = FillColumn(new ContentIterator(nd, shape), shape); return(new XPathNodeView(this, ndRow, columns)); case BindingType.Sequence: case BindingType.Choice: case BindingType.All: int subShapesCount = shape.SubShapes.Count; columns = new object[subShapesCount]; if (shape.BindingType == BindingType.Sequence && shape.SubShape(0).BindingType == BindingType.Attribute) { FillAttributes(ndRow, shape, columns); } Shape lastSubShape = (Shape)shape.SubShapes[subShapesCount - 1]; if (lastSubShape.BindingType == BindingType.Text) //Attributes followed by simpe content or mixed content { columns[subShapesCount - 1] = ndRow; return(new XPathNodeView(this, ndRow, columns)); } else { nd = TreeNavigationHelper.GetContentChild(ndRow); return(FillSubRow(new ContentIterator(nd, shape), shape, columns)); } default: // should not map to a row #if DEBUG throw new NotSupportedException("Unable to bind row to: " + shape.BindingType.ToString()); #else throw new NotSupportedException(); #endif } }
public XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { XPathNodeInfoAtom infoCached; if (this.infoCached == null) { infoCached = new XPathNodeInfoAtom(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } else { infoCached = this.infoCached; this.infoCached = infoCached.Next; infoCached.Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } return this.Atomize(infoCached); }
/// <summary> /// Calculates the neighbour distance /// </summary> /// <param name="inStart">Start node</param> /// <param name="inEnd">End node</param> /// <returns></returns> protected virtual double NeighborDistance(XPathNode inStart, XPathNode inEnd) { int diffX = Math.Abs(inStart.X - inEnd.X); int diffY = Math.Abs(inStart.Y - inEnd.Y); switch (diffX + diffY) { case 1: return(1); case 2: return(Math.Sqrt(2)); default: throw new ApplicationException(); } }
public ContentIterator(XPathNode nd, Shape shape) { this.node = nd; XmlSchemaElement xse = shape.XmlSchemaElement; Debug.Assert(null != xse); SchemaElementDecl decl = xse.ElementDecl; Debug.Assert(null != decl); this.contentValidator = decl.ContentValidator; this.currentState = new ValidationState(); this.contentValidator.InitValidation(this.currentState); this.currentState.ProcessContents = XmlSchemaContentProcessing.Strict; if (nd != null) { Advance(); } }
private int GetFollowingEnd(XPathDocumentNavigator end, bool useParentOfVirtual, out XPathNode[] pageEnd) { if ((end != null) && (this.pageCurrent[this.idxCurrent].Document == end.pageCurrent[end.idxCurrent].Document)) { if (end.idxParent == 0) { pageEnd = end.pageCurrent; return end.idxCurrent; } pageEnd = end.pageParent; if (!useParentOfVirtual) { return (end.idxParent + 1); } return end.idxParent; } pageEnd = null; return 0; }
void DeriveShapeFromRows() { object schemaInfo = null; for (int i = 0; (i < rows.Count) && (null == schemaInfo); i++) { XPathNode nd = rows[i] as XPathNode; Debug.Assert(null != nd && (XPathNodeType.Attribute == nd.NodeType || XPathNodeType.Element == nd.NodeType)); if (null != nd) { if (XPathNodeType.Attribute == nd.NodeType) { schemaInfo = nd.SchemaAttribute; } else { schemaInfo = nd.SchemaElement; } } } if (0 == rows.Count) { // TODO: throw new NotImplementedException("XPath failed to match an elements"); } if (null == schemaInfo) { rows.Clear(); throw new XmlException(SR.XmlDataBinding_NoSchemaType, (string[])null); } ShapeGenerator shapeGen = new ShapeGenerator(this.namespaceResolver); XmlSchemaElement xse = schemaInfo as XmlSchemaElement; if (null != xse) { this.rowShape = shapeGen.GenerateFromSchema(xse); } else { this.rowShape = shapeGen.GenerateFromSchema((XmlSchemaAttribute)schemaInfo); } }
void FillAttributes(XPathNode nd, Shape shape, object[] cols) { int i = 0; while (i < cols.Length) { Shape attrShape = shape.SubShape(i); if (attrShape.BindingType != BindingType.Attribute) { break; } XmlQualifiedName name = attrShape.AttributeName; XPathNode ndAttr = nd.GetAttribute(name.Name, name.Namespace); if (null != ndAttr) { cols[i] = ndAttr; } i++; } }
private void StoreNeighborNodesNoDiagonal(XPathNode inAround, XPathNode[] inNeighbors) { int x = inAround.X; int y = inAround.Y; if (y > 0) { inNeighbors[0] = _mSearchSpace[y - 1, x]; } else { inNeighbors[0] = null; } if (x > 0) { inNeighbors[1] = _mSearchSpace[y, x - 1]; } else { inNeighbors[1] = null; } if (x < Width - 1) { inNeighbors[2] = _mSearchSpace[y, x + 1]; } else { inNeighbors[2] = null; } if (y < Height - 1) { inNeighbors[3] = _mSearchSpace[y + 1, x]; } else { inNeighbors[3] = null; } }
public void Init(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { this.localName = localName; this.namespaceUri = namespaceUri; this.prefix = prefix; this.baseUri = baseUri; this.pageParent = pageParent; this.pageSibling = pageSibling; this.pageSimilar = pageSimilar; this.doc = doc; this.lineNumBase = lineNumBase; this.linePosBase = linePosBase; this.next = null; this.pageInfo = null; this.hashCode = 0; this.localNameHash = 0; for (int i = 0; i < this.localName.Length; i++) { this.localNameHash += (this.localNameHash << 7) ^ this.localName[i]; } }
void PopulateFromXPath(XPathNode nd, XPathStep[] steps, int step) { string ln = steps[step].name.Name; string ns = steps[step].name.Namespace; if (XPathNodeType.Attribute == steps[step].type) { XPathNode ndAttr = nd.GetAttribute(ln, ns, true); if (null != ndAttr) { if (null != ndAttr.SchemaAttribute) { this.rows.Add(ndAttr); } } } else { XPathNode ndChild = TreeNavigationHelper.GetElementChild(nd, ln, ns, true); if (null != ndChild) { int nextStep = step + 1; do { if (steps.Length == nextStep) { if (null != ndChild.SchemaType) { this.rows.Add(ndChild); } } else { PopulateFromXPath(ndChild, steps, nextStep); } ndChild = TreeNavigationHelper.GetElementSibling(ndChild, ln, ns, true); } while (null != ndChild); } } }
/// <include file='doc\XPathDocumentView.uex' path='docs/doc[@for="XPathDocumentView.XPathDocumentView4"]/*' /> public XPathDocumentView(XPathDocument document, string xpath, IXmlNamespaceResolver namespaceResolver, bool showPrefixes) { if (null == document) { throw new ArgumentNullException(nameof(document)); } this.xpath = xpath; this.document = document; this.ndRoot = document.Root; if (null == this.ndRoot) { throw new ArgumentException(nameof(document)); } this.ndRoot = document.Root; this.xpathResolver = namespaceResolver; if (showPrefixes) { this.namespaceResolver = namespaceResolver; } ArrayList rows = new ArrayList(); this.rows = rows; InitFromXPath(this.ndRoot, xpath); }
internal int LookupIdElement(string id, out XPathNode[] pageElem) { if ((this.idValueMap == null) || !this.idValueMap.ContainsKey(id)) { pageElem = null; return 0; } XPathNodeRef ref2 = this.idValueMap[id]; pageElem = ref2.Page; return ref2.Index; }
internal int GetXmlNamespaceNode(out XPathNode[] pageXmlNmsp) { pageXmlNmsp = this.pageXmlNmsp; return this.idxXmlNmsp; }
/// <summary> /// Constructor. /// </summary> public XPathNodePageInfo(XPathNode[] pagePrev, int pageNum) { this.pagePrev = pagePrev; this.pageNum = pageNum; this.nodeCount = 1; // Every node page contains PageInfo at 0th position }
protected virtual double CalculateHeuristicShortestRoute(XPathNode inStart, XPathNode inEnd) { return (Math.Sqrt((inStart.X - inEnd.X) * (inStart.X - inEnd.X) + (inStart.Y - inEnd.Y) * (inStart.Y - inEnd.Y))); }
internal void AddIdElement(string id, XPathNode[] pageElem, int idxElem) { if (this.idValueMap == null) { this.idValueMap = new Dictionary<string, XPathNodeRef>(); } if (!this.idValueMap.ContainsKey(id)) { this.idValueMap.Add(id, new XPathNodeRef(pageElem, idxElem)); } }
internal void SetRootNode(XPathNode[] pageRoot, int idxRoot) { this.pageRoot = pageRoot; this.idxRoot = idxRoot; }
/// <summary> /// Return the page and index of the first child (attribute or content) of the specified node. /// </summary> private static void GetChild(ref XPathNode[] pageNode, ref int idxNode) { Debug.Assert(pageNode[idxNode].HasAttribute || pageNode[idxNode].HasContentChild, "Caller must check HasAttribute/HasContentChild on parent before calling GetChild."); Debug.Assert(pageNode[idxNode].HasAttribute || !pageNode[idxNode].HasCollapsedText, "Text child is virtualized and therefore is not present in the physical node page."); if (++idxNode >= pageNode.Length) { // Child is first node on next page pageNode = pageNode[0].PageInfo.NextPage; idxNode = 1; } // Else child is next node on this page }
protected virtual double CalculateHeuristicExperimental(XPathNode inStart, XPathNode inEnd) { return(CalculateHeuristicFast(inStart, inEnd)); }
/// <summary> /// Returns null, if no path is found. Start- and End-Node are included in returned path. The user context /// is passed to IsWalkable(). /// </summary> public LinkedList <XPathNode> Search(Point inEndNode, Point inStartNode) { ResetSearchSpace(); _mOrderedOpenSet = new PriorityQueue <XPathNode, double>(PathNode.Comparer, Width + Height); _mClosedSet = new bool[Height, Width]; _mOpenSet = new bool[Height, Width]; _startNode = _mSearchSpace[inStartNode.Y, inStartNode.X]; _endNode = _mSearchSpace[inEndNode.Y, inEndNode.X]; if (_startNode == _endNode) { return(new LinkedList <XPathNode>(new[] { _startNode })); } XPathNode[] neighborNodes = _allowDiagonal ? new XPathNode[8] : new XPathNode[4]; TieBreaker = 0; _startNode.G = 0; _startNode.Optimal = _calculationMethod(_startNode, _endNode); TieBreaker = 1d / _startNode.Optimal; _startNode.F = _startNode.Optimal; _mOrderedOpenSet.Push(_startNode); _startNode.ExtraWeight = _size; XPathNode x; while ((x = _mOrderedOpenSet.Pop()) != null) { if (x == _endNode) { LinkedList <XPathNode> result = ReconstructPath(x); result.AddLast(_endNode); return(result); } _mClosedSet[x.Y, x.X] = true; if (_allowDiagonal) { StoreNeighborNodesDiagonal(x, neighborNodes); } else { StoreNeighborNodesNoDiagonal(x, neighborNodes); } foreach (XPathNode t in neighborNodes) { XPathNode y = t; if (y == null) { continue; } if (y.UserItem.IsBlocked(y.X, y.Y, _endNode.X == y.X && _endNode.Y == y.Y)) { continue; } if (_mClosedSet[y.Y, y.X]) { continue; } double trailScore = y.G + 1; bool wasAdded = false; bool scoreResultBetter; if (_mOpenSet[y.Y, y.X] == false) { _mOpenSet[y.Y, y.X] = true; scoreResultBetter = true; wasAdded = true; } else if (trailScore < y.G) { scoreResultBetter = true; } else { scoreResultBetter = false; } if (!scoreResultBetter) { continue; } y.Parent = x; if (wasAdded) { y.G = trailScore; y.Optimal = CalculateHeuristicBetween(y, _endNode) + (x.ExtraWeight - 10); y.ExtraWeight = x.ExtraWeight - 10; y.F = y.G + y.Optimal; _mOrderedOpenSet.Push(y); } else { y.G = trailScore; y.Optimal = CalculateHeuristicBetween(y, _endNode) + (x.ExtraWeight - 10); _mOrderedOpenSet.Update(y, y.G + y.Optimal); y.ExtraWeight = x.ExtraWeight - 10; } } } return(null); }
internal int LookupNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp) { XPathNodeRef key = new XPathNodeRef(pageElem, idxElem); if ((this.mapNmsp == null) || !this.mapNmsp.ContainsKey(key)) { pageNmsp = null; return 0; } key = this.mapNmsp[key]; pageNmsp = key.Page; return key.Index; }
/// <summary> /// Returns the root node of the current document. This always succeeds. /// </summary> public int GetRoot(out XPathNode[] pageNode) { return this.info.Document.GetRootNode(out pageNode); }
internal void SetCollapsedTextNode(XPathNode[] pageText, int idxText) { this.pageText = pageText; this.idxText = idxText; }
/// <summary> /// Returns the next element in document order that has the same local name hashcode as this element. /// If there are no similar elements, then 0 is returned. /// </summary> public int GetSimilarElement(out XPathNode[] pageNode) { pageNode = this.info.SimilarElementPage; return this.idxSimilar; }
internal void SetXmlNamespaceNode(XPathNode[] pageXmlNmsp, int idxXmlNmsp) { this.pageXmlNmsp = pageXmlNmsp; this.idxXmlNmsp = idxXmlNmsp; }
public XPathNodeRef(XPathNode[] page, int idx) { this.page = page; this.idx = idx; }
/// <summary> /// "end" is positioned on a node which terminates a following scan. Return the page and index of "end" if it /// is positioned to a non-virtual node. If "end" is positioned to a virtual node: /// 1. If useParentOfVirtual is true, then return the page and index of the virtual node's parent /// 2. If useParentOfVirtual is false, then return the page and index of the virtual node's parent + 1. /// </summary> private int GetFollowingEnd(XPathDocumentNavigator end, bool useParentOfVirtual, out XPathNode[] pageEnd) { // If ending navigator is positioned to a node in another document, then return null if (end != null && _pageCurrent[_idxCurrent].Document == end._pageCurrent[end._idxCurrent].Document) { // If the ending navigator is not positioned on a virtual node, then return its current node if (end._idxParent == 0) { pageEnd = end._pageCurrent; return end._idxCurrent; } // If the ending navigator is positioned on an attribute, namespace, or virtual text node, then use the // next physical node instead, as the results will be the same. pageEnd = end._pageParent; return (useParentOfVirtual) ? end._idxParent : end._idxParent + 1; } // No following, so set pageEnd to null and return an index of 0 pageEnd = null; return 0; }
internal XPathDocumentView(XPathNode root, ArrayList rows, Shape rowShape) { this.rows = rows; this.rowShape = rowShape; this.ndRoot = root; }
/// <summary> /// Returns the parent of this node. If this node has no parent, then 0 is returned. /// </summary> public int GetParent(out XPathNode[] pageNode) { pageNode = this.info.ParentPage; return this.idxParent; }
/// <summary> /// Set the right xpath node. /// </summary> /// <param name="n"> /// Right node. </param> public virtual void set_right(XPathNode n) { _right = n; }
/// <summary> /// Returns the next sibling of this node. If this node has no next sibling, then 0 is returned. /// </summary> public int GetSibling(out XPathNode[] pageNode) { pageNode = this.info.SiblingPage; return this.idxSibling; }
internal void AddNamespace(XPathNode[] pageElem, int idxElem, XPathNode[] pageNmsp, int idxNmsp) { if (this.mapNmsp == null) { this.mapNmsp = new Dictionary<XPathNodeRef, XPathNodeRef>(); } this.mapNmsp.Add(new XPathNodeRef(pageElem, idxElem), new XPathNodeRef(pageNmsp, idxNmsp)); }
/// <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); } }
internal int GetCollapsedTextNode(out XPathNode[] pageText) { pageText = this.pageText; return this.idxText; }
/// <summary> /// Construct a new shared information atom. This method should only be used by the XNodeInfoTable. /// </summary> public XPathNodeInfoAtom(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); }
internal int GetRootNode(out XPathNode[] pageRoot) { pageRoot = this.pageRoot; return this.idxRoot; }
/// <summary> /// Create a new XNodeInfoAtom and ensure it is atomized in the table. /// </summary> public XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { XPathNodeInfoAtom info; // If this.infoCached already exists, then reuse it; else create new InfoAtom if (this.infoCached == null) { info = new XPathNodeInfoAtom(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } else { info = this.infoCached; this.infoCached = info.Next; info.Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } return Atomize(info); }
internal XPathNodeView(XPathDocumentView col, XPathNode rowNd, object[] columns) { this.collection = col; this.rowNd = rowNd; this.cols = columns; }