private IQuery ProcessAxis(Axis root, IQuery qyInput, int parent, Axis.AxisType parentaxis) { IQuery result = null; String URN = String.Empty; if (root.Prefix.Length > 0) { _hasPrefix = true; } hasReverseAxis = false; switch (root.TypeOfAxis) { case Axis.AxisType.Ancestor: result = new XPathAncestorQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type); _specialAxis = hasReverseAxis = true; break; case Axis.AxisType.AncestorOrSelf: result = new XPathAncestorQuery(qyInput, true, root.Name, root.Prefix, URN, root.Type); _specialAxis = hasReverseAxis = true; break; case Axis.AxisType.Child: if (_slashslash) { result = new XPathDescendantQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type, abbrAxis); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self)) { result = new CacheQuery(result); } _slashslash = false; _specialAxis = true; break; } if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self)) { result = new CacheChildrenQuery(qyInput, root.Name, root.Prefix, URN, root.Type); } else { result = new ChildrenQuery(qyInput, root.Name, root.Prefix, URN, root.Type); } break; case Axis.AxisType.Parent: result = new ParentQuery(qyInput, root.Name, root.Prefix, URN, root.Type); break; case Axis.AxisType.Descendant: switch (parent) { case Smart_D: result = new SmartXPathDescendantQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type); break; case Regular_D: result = new XPathDescendantQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self)) { result = new CacheQuery(result); } _specialAxis = true; break; } break; case Axis.AxisType.DescendantOrSelf: switch (parent) { case Smart_D: result = new SmartXPathDescendantQuery(qyInput, true, root.Name, root.Prefix, URN, root.Type, root.abbrAxis); break; case Regular_D: if (_smart <= 1 || root.Type != XPathNodeType.All || parentaxis != Axis.AxisType.Child) { result = new XPathDescendantQuery( qyInput, true, root.Name, root.Prefix, URN, root.Type, root.abbrAxis); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self)) { result = new CacheQuery(result); } _specialAxis = true; } else { _slashslash = true; abbrAxis = root.abbrAxis; result = qyInput; } break; } break; case Axis.AxisType.Preceding: result = new PrecedingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); _specialAxis = hasReverseAxis = true; break; case Axis.AxisType.Following: result = new FollowingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); _specialAxis = true; break; case Axis.AxisType.FollowingSibling: result = new FollSiblingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self)) { result = new DocumentOrderQuery(result); } break; case Axis.AxisType.PrecedingSibling: result = new PreSiblingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); hasReverseAxis = true; break; case Axis.AxisType.Attribute: result = new AttributeQuery( qyInput, root.Name, root.Prefix, URN, root.Type); break; case Axis.AxisType.Self: result = new XPathSelfQuery( qyInput, root.Name, root.Prefix, URN, root.Type); break; case Axis.AxisType.Namespace: if ( (root.Type == XPathNodeType.All || root.Type == XPathNodeType.Element || root.Type == XPathNodeType.Attribute) && root.Prefix == string.Empty ) { result = new NamespaceQuery(qyInput, root.Name, root.Prefix, URN, root.Type); } else { result = new EmptyNamespaceQuery(); } break; default: throw new XPathException(Res.Xp_NotSupported, _query); } return(result); }
private IQuery ProcessAxis(Axis root , IQuery qyInput, int parent, Axis.AxisType parentaxis) { IQuery result = null; String URN = String.Empty; if ( root.Prefix.Length > 0) { _hasPrefix = true; } hasReverseAxis = false; switch (root.TypeOfAxis) { case Axis.AxisType.Ancestor: result = new XPathAncestorQuery( qyInput , false, root.Name, root.Prefix, URN, root.Type ); _specialAxis = hasReverseAxis = true; break; case Axis.AxisType.AncestorOrSelf: result = new XPathAncestorQuery( qyInput, true, root.Name, root.Prefix, URN, root.Type ); _specialAxis = hasReverseAxis = true; break; case Axis.AxisType.Child: if (_slashslash){ result = new XPathDescendantQuery( qyInput, false, root.Name, root.Prefix, URN, root.Type, abbrAxis); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int) Querytype.Self)) { result = new CacheQuery(result); } _slashslash = false; _specialAxis = true; break; } if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int) Querytype.Self)) result = new CacheChildrenQuery( qyInput, root.Name, root.Prefix, URN, root.Type ); else result = new ChildrenQuery( qyInput, root.Name, root.Prefix, URN, root.Type ); break; case Axis.AxisType.Parent: result = new ParentQuery( qyInput, root.Name, root.Prefix, URN, root.Type ); break; case Axis.AxisType.Descendant: switch (parent) { case Smart_D : result = new SmartXPathDescendantQuery( qyInput, false, root.Name, root.Prefix, URN, root.Type); break; case Regular_D : result = new XPathDescendantQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int) Querytype.Self)) result = new CacheQuery(result); _specialAxis = true; break; } break; case Axis.AxisType.DescendantOrSelf: switch (parent) { case Smart_D : result = new SmartXPathDescendantQuery(qyInput, true, root.Name, root.Prefix, URN, root.Type, root.abbrAxis); break; case Regular_D : if ( _smart <= 1 || root.Type != XPathNodeType.All || parentaxis != Axis.AxisType.Child) { result = new XPathDescendantQuery( qyInput, true, root.Name, root.Prefix, URN, root.Type, root.abbrAxis); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int) Querytype.Self)) result = new CacheQuery(result); _specialAxis = true; } else { _slashslash = true; abbrAxis = root.abbrAxis; result = qyInput; } break; } break; case Axis.AxisType.Preceding: result = new PrecedingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); _specialAxis = hasReverseAxis = true; break; case Axis.AxisType.Following : result = new FollowingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); _specialAxis = true; break; case Axis.AxisType.FollowingSibling : result = new FollSiblingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int) Querytype.Self)) { result = new DocumentOrderQuery(result); } break; case Axis.AxisType.PrecedingSibling : result = new PreSiblingQuery( qyInput, root.Name, root.Prefix, URN, root.Type); hasReverseAxis = true; break; case Axis.AxisType.Attribute: result = new AttributeQuery( qyInput, root.Name, root.Prefix, URN, root.Type); break; case Axis.AxisType.Self: result = new XPathSelfQuery( qyInput, root.Name, root.Prefix, URN, root.Type); break; case Axis.AxisType.Namespace: if ( (root.Type == XPathNodeType.All || root.Type == XPathNodeType.Element || root.Type == XPathNodeType.Attribute) && root.Prefix == string.Empty ) { result = new NamespaceQuery(qyInput, root.Name, root.Prefix, URN, root.Type); } else { result = new EmptyNamespaceQuery(); } break; default: throw new XPathException(Res.Xp_NotSupported, _query); } return result; }