internal XPathSelfQuery( IQuery qyInput, String Name, String Prefix, String URN, XPathNodeType Type) : base(qyInput, Name, Prefix, URN, Type) { }
//public enum XmlNodeType { // None, // Element, // Attribute, // Text, // CDATA, // EntityReference, // Entity, // ProcessingInstruction, // Comment, // Document, // DocumentType, // DocumentFragment, // Notation, // Whitespace, // SignificantWhitespace, // EndElement, // EndEntity, // XmlDeclaration //} //public enum XPathNodeType { // Root, // Element, // Attribute, // Namespace, // Text, // SignificantWhitespace, // Whitespace, // ProcessingInstruction, // Comment, // All, //} // xpath defines its own NodeType // it should use the XmlNodeType instead // we just map between them for now // so that the construct query will have // the XmlNodeType instead of XPathNodeType XmlNodeType MapNodeType(XPathNodeType type) { XmlNodeType ret = XmlNodeType.None; switch (type) { case XPathNodeType.Element: ret = XmlNodeType.Element; break; case XPathNodeType.Attribute: ret = XmlNodeType.Attribute; break; case XPathNodeType.Text: ret = XmlNodeType.Text; break; case XPathNodeType.ProcessingInstruction: ret = XmlNodeType.ProcessingInstruction; break; case XPathNodeType.Comment: ret = XmlNodeType.Comment; break; default: break; } return ret; }
internal bool DecideXPNodeTypeForTextNodes(XmlNode node, ref XPathNodeType xnt) { while (node != null) { switch (node.NodeType) { case XmlNodeType.Text: case XmlNodeType.CDATA: xnt = XPathNodeType.Text; return false; case XmlNodeType.EntityReference: if (this.DecideXPNodeTypeForTextNodes(node.FirstChild, ref xnt)) { break; } return false; case XmlNodeType.Whitespace: break; case XmlNodeType.SignificantWhitespace: xnt = XPathNodeType.SignificantWhitespace; break; default: return false; } node = node.NextSibling; } return true; }
public static bool DecideXPNodeTypeForTextNodes(this XmlNode thisObj, XmlNode node, ref XPathNodeType xnt) { //returns true - if all siblings of the node are processed else returns false. //The reference XPathNodeType argument being passed in is the watermark that //changes according to the siblings nodetype and will contain the correct //nodetype when it returns. Debug.Assert(IsTextNode(node.NodeType) || (node.ParentNode != null && node.ParentNode.NodeType == XmlNodeType.EntityReference)); while (node != null) { switch (node.NodeType) { case XmlNodeType.Whitespace: break; case XmlNodeType.SignificantWhitespace: xnt = XPathNodeType.SignificantWhitespace; break; case XmlNodeType.Text: case XmlNodeType.CDATA: xnt = XPathNodeType.Text; return false; case XmlNodeType.EntityReference: if (!thisObj.DecideXPNodeTypeForTextNodes(node.FirstChild, ref xnt)) { return false; } break; default: return false; } node = node.NextSibling; } return true; }
/// <summary> /// Creates an XPathNodeMatch from the navigator which should be position on the /// node. /// </summary> /// <remarks> /// We deliberately use the OuterXml when we find a Namespace since the /// navigator location returned starts from the xmlns attribute. /// </remarks> public XPathNodeMatch(XPathNavigator currentNavigator) { SetLineNumbers(currentNavigator as IXmlLineInfo); nodeType = currentNavigator.NodeType; switch (nodeType) { case XPathNodeType.Text: SetTextValue(currentNavigator); break; case XPathNodeType.Comment: SetCommentValue(currentNavigator); break; case XPathNodeType.Namespace: SetNamespaceValue(currentNavigator); break; case XPathNodeType.Element: SetElementValue(currentNavigator); break; case XPathNodeType.ProcessingInstruction: SetProcessingInstructionValue(currentNavigator); break; case XPathNodeType.Attribute: SetAttributeValue(currentNavigator); break; default: value = currentNavigator.LocalName; displayValue = value; break; } }
internal ChildrenQuery( IQuery qyInput, String name, String prefix, String urn, XPathNodeType type) : base (qyInput, name, prefix, urn, type) { }
/// <summary> /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately). /// Initialize output state to accept Rtf content (top-level sequences are therefore prohibited). /// </summary> internal XmlQueryOutput(XmlQueryRuntime runtime, XmlEventCache xwrt) { this.runtime = runtime; this.xwrt = xwrt; this.xstate = XmlState.WithinContent; this.depth = 1; this.rootType = XPathNodeType.Root; }
internal AttributeQuery( IQuery qyParent, String Name, String Prefix, String URN, XPathNodeType Type) : base(qyParent, Name, Prefix, URN, Type) { }
// constructor internal Axis(AxisType axistype, AstNode input) { _axistype = axistype; _input = input; _prefix = String.Empty; _name = String.Empty; _nodetype = XPathNodeType.All; this.abbrAxis = true; }
/// <summary> /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately). /// Initialize output state to accept Rtf content (top-level sequences are therefore prohibited). /// </summary> internal XmlQueryOutput(XmlQueryRuntime runtime, XmlEventCache xwrt) { _runtime = runtime; _xwrt = xwrt; _xstate = XmlState.WithinContent; _depth = 1; _rootType = XPathNodeType.Root; }
public XPathNodeMatch(string nodeValue, string displayValue, int? lineNumber, int linePosition, XPathNodeType nodeType) { this.nodeValue = nodeValue; this.displayValue = displayValue; this.lineNumber = lineNumber; this.linePosition = linePosition; this.nodeType = nodeType; }
XPathObjectNavigator(XPathObjectNavigator that) { _context = that._context; _root = that._root; _node = that._node; _type = that._type; _index = that._index; }
public XslTemplateContent (Compiler c, XPathNodeType parentType, bool xslForEach) : base (c) { this.parentType = parentType; this.xslForEach = xslForEach; Compile (c); }
internal FollSiblingQuery( IQuery qyInput, String name, String prefix, String urn, XPathNodeType type) : base (qyInput, name, prefix, urn, type) { }
/// <summary> /// Start construction of a new Xml tree (document or fragment). /// </summary> public override XmlRawWriter StartTree(XPathNodeType rootType, IXmlNamespaceResolver nsResolver, XmlNameTable nameTable) { // Build XPathDocument // If rootType != XPathNodeType.Root, then build an XQuery fragment this.doc = new XPathDocument(nameTable); this.writer = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames | (rootType == XPathNodeType.Root ? XPathDocument.LoadFlags.None : XPathDocument.LoadFlags.Fragment), string.Empty); this.writer.NamespaceResolver = nsResolver; return this.writer; }
protected BaseAxisQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) { this.qyInput = qyInput; this.name = name; this.prefix = prefix; this.typeTest = typeTest; this.nameTest = (prefix.Length != 0) || (name.Length != 0); this.nsUri = string.Empty; }
internal XPathAncestorQuery( IQuery qyInput, bool matchSelf, String Name, String Prefix, String URN, XPathNodeType Type) : base(qyInput, Name, Prefix, URN, Type) { _fMatchSelf = matchSelf; }
private static void CompareNodeTypes(XPathNodeType a, XPathNodeType b) { // XPath.XDocument interprets whitespaces as XPathNodeType.Text // while other XPath navigators do it properly if (!IsWhitespaceOrText(a) && !IsWhitespaceOrText(b)) { Assert.Equal(a, b); } }
// constructor public Axis(AxisType axisType, AstNode input, string prefix, string name, XPathNodeType nodetype) { Debug.Assert(prefix != null); Debug.Assert(name != null); this.axisType = axisType; this.input = input; this.prefix = prefix; this.name = name; this.nodeType = nodetype; }
public Axis(AxisType axisType, AstNode input, string prefix, string name, XPathNodeType nodetype) { this.urn = string.Empty; this.axisType = axisType; this.input = input; this.prefix = prefix; this.name = name; this.nodeType = nodetype; }
protected BaseAxisQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) { Debug.Assert(qyInput != null); this.qyInput = qyInput; this.name = name; this.prefix = prefix; this.typeTest = typeTest; this.nameTest = prefix.Length != 0 || name.Length != 0; this.nsUri = string.Empty; }
public XPathAxisIterator(XPathAxisIterator it) { this.nav = it.nav.Clone(); this.type = it.type; this.name = it.name; this.uri = it.uri; this.position = it.position; this.matchSelf = it.matchSelf; this.first = it.first; }
internal XPathDescendantQuery( IQuery qyParent, bool matchSelf, String Name, String Prefix, String URN, XPathNodeType Type) : base(qyParent, Name, Prefix, URN, Type) { _fMatchSelf = matchSelf; }
public static int GetKindMask(XPathNodeType type) { if (type == XPathNodeType.All) return AllMask; else if (type == XPathNodeType.Text) return TextMask; return (1 << (int)type); }
public XPathDocumentKindDescendantIterator(XPathDocumentNavigator root, XPathNodeType typ, bool matchSelf) : base(root) { this.typ = typ; this.matchSelf = matchSelf; if (root.NodeType != XPathNodeType.Root) { this.end = new XPathDocumentNavigator(root); this.end.MoveToNonDescendant(); } }
protected BaseAxisQuery(BaseAxisQuery other) : base(other) { this.qyInput = Clone(other.qyInput); this.name = other.name; this.prefix = other.prefix; this.nsUri = other.nsUri; this.typeTest = other.typeTest; this.nameTest = other.nameTest; this.position = other.position; this.currentNode = other.currentNode; }
// constructor public Axis(AxisType axisType, AstNode input, string prefix, string name, XPathNodeType nodetype) { Debug.Assert(prefix != null); Debug.Assert(name != null); _axisType = axisType; _input = input; _prefix = prefix; _name = name; _nodeType = nodetype; }
private static bool AreComparableNodes(XPathNodeType a, XPathNodeType b) { bool areBothTextOrWhitespaces = IsWhitespaceOrText(a) && IsWhitespaceOrText(b); bool areBothNamespacesOrAttributes = IsNamespaceOrAttribute(a) && IsNamespaceOrAttribute(b); #if CHECK_ATTRIBUTE_ORDER areBothNamespacesOrAttributes = false #endif return !areBothTextOrWhitespaces && !areBothNamespacesOrAttributes; }
internal SmartXPathDescendantQuery( IQuery qyParent, bool matchSelf, String Name, String Prefix, String URN, XPathNodeType Type, bool abbrAxis) : base(qyParent,matchSelf, Name, Prefix, URN, Type, abbrAxis) { }
internal XPathDescendantQuery( IQuery qyParent, bool matchSelf, String Name, String Prefix, String URN, XPathNodeType Type, bool abbrAxis) : this(qyParent, matchSelf, Name, Prefix, URN, Type) { this.abbrAxis = abbrAxis; }
public FollSiblingQuery(Query qyInput, string name, string prefix, XPathNodeType type) : base(qyInput, name, prefix, type) { _elementStk = new StackNav(); _parentStk = new List <XPathNavigator>(); }
public XPathChildIterator(XPathNavigator nav, XPathNodeType type) : base(nav, type, /*matchSelf:*/ false) { }
private static QilLoop BuildAxisFilter(QilPatternFactory f, QilIterator itr, XPathAxis xpathAxis, XPathNodeType nodeType, string?name, string?nsUri) { QilNode nameTest = ( name != null && nsUri != null ? f.Eq(f.NameOf(itr), f.QName(name, nsUri)) : // ns:bar || bar nsUri != null ? f.Eq(f.NamespaceUriOf(itr), f.String(nsUri)) : // ns:* name != null ? f.Eq(f.LocalNameOf(itr), f.String(name)) : // *:foo /*name == nsUri == null*/ f.True() // * ); XmlNodeKindFlags intersection = XPathBuilder.AxisTypeMask(itr.XmlType !.NodeKinds, nodeType, xpathAxis); QilNode typeTest = ( intersection == 0 ? f.False() : // input & required doesn't intersect intersection == itr.XmlType.NodeKinds ? f.True() : // input is subset of required /*else*/ f.IsType(itr, T.NodeChoice(intersection)) ); QilLoop filter = f.BaseFactory.Filter(itr, f.And(typeTest, nameTest)); filter.XmlType = T.PrimeProduct(T.NodeChoice(intersection), filter.XmlType !.Cardinality); return(filter); }
public virtual void WriteNode(XPathNavigator navigator, bool defattr) { if (navigator == null) { throw new ArgumentNullException(nameof(navigator)); } int iLevel = 0; navigator = navigator.Clone(); while (true) { bool mayHaveChildren = false; XPathNodeType nodeType = navigator.NodeType; switch (nodeType) { case XPathNodeType.Element: WriteStartElement(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI); // Copy attributes if (navigator.MoveToFirstAttribute()) { do { IXmlSchemaInfo?schemaInfo = navigator.SchemaInfo; if (defattr || (schemaInfo == null || !schemaInfo.IsDefault)) { WriteStartAttribute(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI); // copy string value to writer WriteString(navigator.Value); WriteEndAttribute(); } } while (navigator.MoveToNextAttribute()); navigator.MoveToParent(); } // Copy namespaces if (navigator.MoveToFirstNamespace(XPathNamespaceScope.Local)) { WriteLocalNamespaces(navigator); navigator.MoveToParent(); } mayHaveChildren = true; break; case XPathNodeType.Attribute: // do nothing on root level attribute break; case XPathNodeType.Text: WriteString(navigator.Value); break; case XPathNodeType.SignificantWhitespace: case XPathNodeType.Whitespace: WriteWhitespace(navigator.Value); break; case XPathNodeType.Root: mayHaveChildren = true; break; case XPathNodeType.Comment: WriteComment(navigator.Value); break; case XPathNodeType.ProcessingInstruction: WriteProcessingInstruction(navigator.LocalName, navigator.Value); break; case XPathNodeType.Namespace: // do nothing on root level namespace break; default: Debug.Fail($"Unexpected node type {nodeType}"); break; } if (mayHaveChildren) { // If children exist, move down to next level if (navigator.MoveToFirstChild()) { iLevel++; continue; } else { // EndElement if (navigator.NodeType == XPathNodeType.Element) { if (navigator.IsEmptyElement) { WriteEndElement(); } else { WriteFullEndElement(); } } } } // No children while (true) { if (iLevel == 0) { // The entire subtree has been copied return; } if (navigator.MoveToNext()) { // Found a sibling, so break to outer loop break; } // No siblings, so move up to previous level iLevel--; navigator.MoveToParent(); // EndElement if (navigator.NodeType == XPathNodeType.Element) { WriteFullEndElement(); } } } }
public QilNode Axis(XPathAxis xpathAxis, XPathNodeType nodeType, string?prefix, string?name) { Debug.Assert( xpathAxis == XPathAxis.Child || xpathAxis == XPathAxis.Attribute || xpathAxis == XPathAxis.DescendantOrSelf || xpathAxis == XPathAxis.Root ); QilLoop result; double priority; switch (xpathAxis) { case XPathAxis.DescendantOrSelf: Debug.Assert(nodeType == XPathNodeType.All && prefix == null && name == null, " // is the only d-o-s axes that we can have in pattern"); return(_f.Nop(_fixupNode)); // We using Nop as a flag that DescendantOrSelf exis was used between steps. case XPathAxis.Root: QilIterator i; result = _f.BaseFactory.Filter(i = _f.For(_fixupNode), _f.IsType(i, T.Document)); priority = 0.5; break; default: string?nsUri = prefix == null ? null : _environment.ResolvePrefix(prefix); result = BuildAxisFilter(_f, _f.For(_fixupNode), xpathAxis, nodeType, name, nsUri); switch (nodeType) { case XPathNodeType.Element: case XPathNodeType.Attribute: if (name != null) { priority = 0; } else { if (prefix != null) { priority = -0.25; } else { priority = -0.5; } } break; case XPathNodeType.ProcessingInstruction: priority = name != null ? 0 : -0.5; break; default: priority = -0.5; break; } break; } SetPriority(result, priority); SetLastParent(result, result); return(result); }
public override bool MoveToChild(XPathNodeType type) { return(base.MoveToChild(type)); }
/// <summary> /// Return false or throw if the specified name parts are not valid according to the rules of "nodeKind". Check only rules /// that are specified by the Flags. /// NOTE: Namespaces should be passed using a prefix, ns pair. "localName" is always string.Empty. /// </summary> private static bool ValidateNameInternal(string prefix, string localName, string ns, XPathNodeType nodeKind, Flags flags, bool throwOnError) { Debug.Assert(prefix != null && localName != null && ns != null); if ((flags & Flags.NCNames) != 0) { // 1. Verify that each non-empty prefix and localName is a valid NCName if (prefix.Length != 0) { if (!ParseNCNameInternal(prefix, throwOnError)) { return(false); } } if (localName.Length != 0) { if (!ParseNCNameInternal(localName, throwOnError)) { return(false); } } } if ((flags & Flags.CheckLocalName) != 0) { // 2. Determine whether the local name is valid switch (nodeKind) { case XPathNodeType.Element: // Elements and attributes must have a non-empty local name if (localName.Length == 0) { if (throwOnError) { throw new XmlException(SR.Xdom_Empty_LocalName, string.Empty); } return(false); } break; case XPathNodeType.Attribute: // Attribute local name cannot be "xmlns" if namespace is empty if (ns.Length == 0 && localName.Equals("xmlns")) { if (throwOnError) { throw new XmlException(SR.XmlBadName, new string[] { nodeKind.ToString(), localName }); } return(false); } goto case XPathNodeType.Element; case XPathNodeType.ProcessingInstruction: // PI's local-name must be non-empty and cannot be 'xml' (case-insensitive) if (localName.Length == 0 || (localName.Length == 3 && StartsWithXml(localName))) { if (throwOnError) { throw new XmlException(SR.Xml_InvalidPIName, localName); } return(false); } break; default: // All other node types must have empty local-name if (localName.Length != 0) { if (throwOnError) { throw new XmlException(SR.XmlNoNameAllowed, nodeKind.ToString()); } return(false); } break; } } if ((flags & Flags.CheckPrefixMapping) != 0) { // 3. Determine whether the prefix is valid switch (nodeKind) { case XPathNodeType.Element: case XPathNodeType.Attribute: case XPathNodeType.Namespace: if (ns.Length == 0) { // If namespace is empty, then prefix must be empty if (prefix.Length != 0) { if (throwOnError) { throw new XmlException(SR.Xml_PrefixForEmptyNs, string.Empty); } return(false); } } else { // Don't allow empty attribute prefix since namespace is non-empty if (prefix.Length == 0 && nodeKind == XPathNodeType.Attribute) { if (throwOnError) { throw new XmlException(SR.XmlBadName, new string[] { nodeKind.ToString(), localName }); } return(false); } if (prefix.Equals("xml")) { // xml prefix must be mapped to the xml namespace if (!ns.Equals(XmlReservedNs.NsXml)) { if (throwOnError) { throw new XmlException(SR.Xml_XmlPrefix, string.Empty); } return(false); } } else if (prefix.Equals("xmlns")) { // Prefix may never be 'xmlns' if (throwOnError) { throw new XmlException(SR.Xml_XmlnsPrefix, string.Empty); } return(false); } else if (IsReservedNamespace(ns)) { // Don't allow non-reserved prefixes to map to xml or xmlns namespaces if (throwOnError) { throw new XmlException(SR.Xml_NamespaceDeclXmlXmlns, string.Empty); } return(false); } } break; case XPathNodeType.ProcessingInstruction: // PI's prefix and namespace must be empty if (prefix.Length != 0 || ns.Length != 0) { if (throwOnError) { throw new XmlException(SR.Xml_InvalidPIName, CreateName(prefix, localName)); } return(false); } break; default: // All other node types must have empty prefix and namespace if (prefix.Length != 0 || ns.Length != 0) { if (throwOnError) { throw new XmlException(SR.XmlNoNameAllowed, nodeKind.ToString()); } return(false); } break; } } return(true); }
internal override void Execute(Processor processor, ActionFrame frame) { Debug.Assert(processor != null && frame != null); while (processor.CanContinue) { switch (frame.State) { case Initialized: if (frame.NextNode(processor)) { frame.State = BeginEvent; goto case BeginEvent; } else { frame.Finished(); break; } case BeginEvent: Debug.Assert(frame.State == BeginEvent); if (SendBeginEvent(processor, frame.Node !) == false) { // This one wasn't output break; } frame.State = Contents; continue; case Contents: Debug.Assert(frame.State == Contents); XPathNodeType nodeType = frame.Node !.NodeType; if (nodeType == XPathNodeType.Element || nodeType == XPathNodeType.Root) { processor.PushActionFrame(CopyNamespacesAction.GetAction(), frame.NodeSet); frame.State = Namespaces; break; } if (SendTextEvent(processor, frame.Node) == false) { // This one wasn't output break; } frame.State = EndEvent; continue; case Namespaces: processor.PushActionFrame(CopyAttributesAction.GetAction(), frame.NodeSet); frame.State = Attributes; break; case Attributes: if (frame.Node !.HasChildren) { processor.PushActionFrame(GetAction(), frame.Node.SelectChildren(XPathNodeType.All)); frame.State = Subtree; break; } frame.State = EndEvent; goto case EndEvent; case Subtree: //frame.Node.MoveToParent(); frame.State = EndEvent; continue; case EndEvent: Debug.Assert(frame.State == EndEvent); if (SendEndEvent(processor, frame.Node !) == false) { // This one wasn't output break; } frame.State = Initialized; continue; } break; } }
private SpecialChildNodeIterator(SpecialChildNodeIterator src) { AssignFrom(src); kind = src.kind; }
/// <summary> /// Get the next node that: /// 1. Follows the current node in document order (includes descendants, unlike XPath following axis) /// 2. Precedes the ending node in document order (if pageEnd is null, then all following nodes in the document are considered) /// 3. Has the specified XPathNodeType (but Attributes and Namespaces never match) /// If no such node exists, then do not set pageCurrent or idxCurrent and return false. /// </summary> public static bool GetContentFollowing(ref XPathNode[] pageCurrent, ref int idxCurrent, XPathNode[] pageEnd, int idxEnd, XPathNodeType typ) { XPathNode[] page = pageCurrent; int idx = idxCurrent; int mask = XPathNavigator.GetContentKindMask(typ); Debug.Assert(pageCurrent != null && idxCurrent != 0, "Cannot pass null argument(s)"); Debug.Assert(typ != XPathNodeType.Text, "Text should be handled by GetTextFollowing in order to take into account collapsed text."); Debug.Assert(page[idx].NodeType != XPathNodeType.Attribute, "Current node should never be an attribute or namespace--caller should handle this case."); // Since nodes are laid out in document order on pages, scan them sequentially // rather than following sibling/child/parent links. idx++; do { if ((object)page == (object)pageEnd && idx <= idxEnd) { // Only scan to termination point while (idx != idxEnd) { if (((1 << (int)page[idx].NodeType) & mask) != 0) { goto FoundNode; } idx++; } break; } else { // Scan all nodes in the page while (idx < page[0].PageInfo.NodeCount) { if (((1 << (int)page[idx].NodeType) & mask) != 0) { goto FoundNode; } idx++; } } page = page[0].PageInfo.NextPage; idx = 1; }while (page != null); return(false); FoundNode: Debug.Assert(!page[idx].IsAttrNmsp, "GetContentFollowing should never return attributes or namespaces."); // Found match pageCurrent = page; idxCurrent = idx; return(true); }
private FollowingNodeIterator(FollowingNodeIterator src) { AssignFrom(src); kind = src.kind; }
private static int GetElementContentMask(XPathNodeType type) { return(s_ElementContentMasks[(int)type]); }
/// <summary> /// Throw if the specified name parts are not valid according to the rules of "nodeKind". Check only rules that are /// specified by the Flags. /// NOTE: Namespaces should be passed using a prefix, ns pair. "localName" is always string.Empty. /// </summary> internal static void ValidateNameThrow(string prefix, string localName, string ns, XPathNodeType nodeKind, Flags flags) { // throwOnError = true ValidateNameInternal(prefix, localName, ns, nodeKind, flags, true); }
public XPathAncestorIterator(XPathNavigator nav, XPathNodeType type, bool matchSelf) : base(nav, type, matchSelf) { }
internal bool BeginEvent(XPathNodeType nodeType, string prefix, string name, string nspace, bool empty) { return(BeginEvent(nodeType, prefix, name, nspace, empty, null, true)); }
public AttributeQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type) : base(qyParent, Name, Prefix, Type) { }
/// <summary> /// Return a following sibling of the specified node that has the specified type. If no such /// sibling exists, then do not set pageNode or idxNode and return false. /// </summary> public static bool GetContentSibling(ref XPathNode[] pageNode, ref int idxNode, XPathNodeType typ) { XPathNode[] page = pageNode; int idx = idxNode; int mask = XPathNavigator.GetContentKindMask(typ); Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); if (page[idx].NodeType != XPathNodeType.Attribute) { while (true) { idx = page[idx].GetSibling(out page); if (idx == 0) { break; } if (((1 << (int)page[idx].NodeType) & mask) != 0) { Debug.Assert(typ != XPathNodeType.Attribute && typ != XPathNodeType.Namespace); pageNode = page; idxNode = idx; return(true); } } } return(false); }
internal EndEvent(XPathNodeType nodeType) { Debug.Assert(nodeType != XPathNodeType.Namespace); _nodeType = nodeType; }
/// <summary> /// Return the first child of the specified node that has the specified type (must be a content type). If no such /// child exists, then do not set pageNode or idxNode and return false. /// </summary> public static bool GetContentChild(ref XPathNode[] pageNode, ref int idxNode, XPathNodeType typ) { XPathNode[] page = pageNode; int idx = idxNode; int mask; Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); // Only check children if at least one content-typed child exists if (page[idx].HasContentChild) { mask = XPathNavigator.GetContentKindMask(typ); GetChild(ref page, ref idx); do { if (((1 << (int)page[idx].NodeType) & mask) != 0) { // Never return attributes, as Attribute is not a content type if (typ == XPathNodeType.Attribute) { return(false); } pageNode = page; idxNode = idx; return(true); } idx = page[idx].GetSibling(out page); }while (idx != 0); } return(false); }
/// <summary> /// Create a new iterator that is a copy of "iter". /// </summary> public XPathDocumentKindDescendantIterator(XPathDocumentKindDescendantIterator iter) : base(iter) { _end = iter._end; _typ = iter._typ; _matchSelf = iter._matchSelf; }
public override bool MoveToFollowing(XPathNodeType type, XPathNavigator end) { return(base.MoveToFollowing(type, end)); }
/// <summary> /// Create a new iterator that is a copy of "iter". /// </summary> public XPathDocumentKindChildIterator(XPathDocumentKindChildIterator iter) : base(iter) { _typ = iter._typ; }
public override bool MoveToNext(XPathNodeType type) { return(base.MoveToNext(type)); }
/// <summary> /// Create an iterator that ranges over all content children of "parent" having the specified XPathNodeType. /// </summary> public XPathDocumentKindChildIterator(XPathDocumentNavigator parent, XPathNodeType typ) : base(parent) { _typ = typ; }
public PrecedingQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) : base(qyInput, name, prefix, typeTest) { _ancestorStk = new StackNav(); }
/// <summary> /// Return false if the specified name parts are not valid according to the rules of "nodeKind". Check only rules that are /// specified by the Flags. /// NOTE: Namespaces should be passed using a prefix, ns pair. "localName" is always string.Empty. /// </summary> internal static bool ValidateName(string prefix, string localName, string ns, XPathNodeType nodeKind, Flags flags) { // throwOnError = false return(ValidateNameInternal(prefix, localName, ns, nodeKind, flags, false)); }
public DescendantBaseQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type, bool matchSelf, bool abbrAxis) : base(qyParent, Name, Prefix, Type) { this.matchSelf = matchSelf; this.abbrAxis = abbrAxis; }
public void Read() { if (!skipRead) { if (!xmlReader.Read()) { return; } } skipRead = false; int parent = parentStack [parentStackIndex]; int prevSibling = nodeIndex; switch (xmlReader.NodeType) { case XmlNodeType.Element: case XmlNodeType.CDATA: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Comment: case XmlNodeType.Text: case XmlNodeType.ProcessingInstruction: if (parent == nodeIndex) { prevSibling = 0; } else { while (nodes [prevSibling].Parent != parent) { prevSibling = nodes [prevSibling].Parent; } } nodeIndex++; if (prevSibling != 0) { nodes [prevSibling].NextSibling = nodeIndex; } if (parentStack [parentStackIndex] == nodeIndex - 1) { nodes [parent].FirstChild = nodeIndex; } break; case XmlNodeType.Whitespace: if (xmlSpace == XmlSpace.Preserve) { goto case XmlNodeType.Text; } else { goto default; } case XmlNodeType.EndElement: parentStackIndex--; return; default: // No operations. Doctype, EntityReference, return; } string value = null; XPathNodeType nodeType = XPathNodeType.Text; switch (xmlReader.NodeType) { case XmlNodeType.Element: ProcessElement(parent, prevSibling); break; case XmlNodeType.SignificantWhitespace: nodeType = XPathNodeType.SignificantWhitespace; goto case XmlNodeType.Text; case XmlNodeType.Whitespace: nodeType = XPathNodeType.Whitespace; goto case XmlNodeType.Text; case XmlNodeType.CDATA: case XmlNodeType.Text: AddNode(parent, 0, prevSibling, nodeType, xmlReader.BaseURI, xmlReader.IsEmptyElement, xmlReader.LocalName, // for PI xmlReader.NamespaceURI, // for PI xmlReader.Prefix, value, xmlReader.XmlLang, nsIndex, lineInfo != null ? lineInfo.LineNumber : 0, lineInfo != null ? lineInfo.LinePosition : 0); // this code is tricky, but after sequential // Read() invokation, xmlReader is moved to // next node. if (value == null) { bool loop = true; value = String.Empty; XPathNodeType type = XPathNodeType.Whitespace; do { switch (xmlReader.NodeType) { case XmlNodeType.Text: case XmlNodeType.CDATA: type = XPathNodeType.Text; goto case XmlNodeType.Whitespace; case XmlNodeType.SignificantWhitespace: if (type == XPathNodeType.Whitespace) { type = XPathNodeType.SignificantWhitespace; } goto case XmlNodeType.Whitespace; case XmlNodeType.Whitespace: if (xmlReader.NodeType != XmlNodeType.Whitespace || xmlSpace == XmlSpace.Preserve) { value += xmlReader.Value; } loop = xmlReader.Read(); skipRead = true; continue; default: loop = false; break; } }while (loop); nodes [nodeIndex].Value = value; nodes [nodeIndex].NodeType = type; } break; case XmlNodeType.Comment: value = xmlReader.Value; nodeType = XPathNodeType.Comment; goto case XmlNodeType.Text; case XmlNodeType.ProcessingInstruction: value = xmlReader.Value; nodeType = XPathNodeType.ProcessingInstruction; goto case XmlNodeType.Text; } }
public FollowingQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) : base(qyInput, name, prefix, typeTest) { }
private SpecialDescendantNodeIterator(SpecialDescendantNodeIterator src) { AssignFrom(src); kind = src.kind; }