public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { //StreamUtil.WriteText("I:\\debug.txt","进到 MoveToNextNamespace()\r\n"); Debug.Assert(this.m_navigatorState.CurItem != null, ""); if (this.m_navigatorState.CurItem == this.m_navigatorState.VirtualRoot) return false; if (!(this.m_navigatorState.CurItem is AttrItem)) return false; AttrItem attr = (AttrItem)this.m_navigatorState.CurItem; if (attr.IsNamespace == false) return false; ElementItem element = (ElementItem)attr.parent; ItemList namespaceList = element.NamespaceList; if (namespaceList.Count > 0) { int nIndex = namespaceList.IndexOf(this.m_navigatorState.CurItem); if (nIndex == -1) return false; if (nIndex + 1 >= namespaceList.Count) return false; this.m_navigatorState.CurItem = namespaceList[nIndex + 1]; return true; } return false; }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { return(_decoratedNavigator.MoveToNextNamespace(namespaceScope)); }
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { return false; }
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { this.IncrementNodeCount(); return this.navigator.MoveToFirstNamespace(namespaceScope); }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { this.currentPosition = -1L; return this.navigator.MoveToNextNamespace(namespaceScope); }
public override bool MoveToNextNamespace (XPathNamespaceScope namespaceScope) { if (NsNode == Document.NsNodeXml) // Current namespace is "xml", so there should be no more namespace nodes. return false; if (NsNode == null) return false; // Get current attribute's position. int pos = 0; XmlElement owner = ((XmlAttribute) NsNode).OwnerElement; if (owner == null) return false; int count = owner.Attributes.Count; for(; pos < count; pos++) if (owner.Attributes [pos] == NsNode) break; if (pos == count) return false; // Where is current attribute? Maybe removed. // Find next namespace from the same element as current ns node. for(pos++; pos < count; pos++) { if (owner.Attributes [pos].NamespaceURI == Xmlns) { XmlAttribute a = owner.Attributes [pos]; if (CheckNsNameAppearance (a.Name, a.Value)) continue; NsNode = a; return true; } } // If not found more, then find from ancestors. // But if scope is Local, then it returns false here. if (namespaceScope == XPathNamespaceScope.Local) return false; owner = GetParentNode (owner) as XmlElement; while (owner != null) { if (owner.HasAttributes) { for (int i = 0; i < owner.Attributes.Count; i++) { XmlAttribute attr = owner.Attributes [i]; if (attr.NamespaceURI == Xmlns) { if (CheckNsNameAppearance (attr.Name, attr.Value)) continue; NsNode = attr; return true; } } } owner = GetParentNode (owner) as XmlElement; } if (namespaceScope == XPathNamespaceScope.All) { if (CheckNsNameAppearance (Document.NsNodeXml.Name, Document.NsNodeXml.Value)) return false; NsNode = Document.NsNodeXml; return true; } return false; }
public abstract NavigatorAdapter MoveToFirstNamespace(XPathNamespaceScope namespaceScope);
/// <inheritdoc /> public override Boolean MoveToNextNamespace(XPathNamespaceScope namespaceScope) { return(false); }
/// <summary> /// Moves the XPathNavigator to the next namespace node matching the XPathNamespaceScope specified. /// </summary> /// <param name="namespaceScope">An XPathNamespaceScope value describing the namespace scope. </param> /// <returns> /// Returns true if the XPathNavigator is successful moving to the next namespace node; /// otherwise, false. If false, the position of the XPathNavigator is unchanged. /// </returns> public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { DebugEnter("MoveToNextNamespace"); DebugReturn(false); return(false); }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { if (this.NsNode == this.Document.NsNodeXml) { return(false); } if (this.NsNode == null) { return(false); } int i = 0; XmlElement xmlElement = this.NsNode.OwnerElement; if (xmlElement == null) { return(false); } int count = xmlElement.Attributes.Count; while (i < count) { if (xmlElement.Attributes[i] == this.NsNode) { break; } i++; } if (i == count) { return(false); } for (i++; i < count; i++) { if (xmlElement.Attributes[i].NamespaceURI == "http://www.w3.org/2000/xmlns/") { XmlAttribute xmlAttribute = xmlElement.Attributes[i]; if (!this.CheckNsNameAppearance(xmlAttribute.Name, xmlAttribute.Value)) { this.NsNode = xmlAttribute; return(true); } } } if (namespaceScope == XPathNamespaceScope.Local) { return(false); } for (xmlElement = (this.GetParentNode(xmlElement) as XmlElement); xmlElement != null; xmlElement = (this.GetParentNode(xmlElement) as XmlElement)) { if (xmlElement.HasAttributes) { for (int j = 0; j < xmlElement.Attributes.Count; j++) { XmlAttribute xmlAttribute2 = xmlElement.Attributes[j]; if (xmlAttribute2.NamespaceURI == "http://www.w3.org/2000/xmlns/") { if (!this.CheckNsNameAppearance(xmlAttribute2.Name, xmlAttribute2.Value)) { this.NsNode = xmlAttribute2; return(true); } } } } } if (namespaceScope != XPathNamespaceScope.All) { return(false); } if (this.CheckNsNameAppearance(this.Document.NsNodeXml.Name, this.Document.NsNodeXml.Value)) { return(false); } this.NsNode = this.Document.NsNodeXml; return(true); }
public override bool MoveToNextNamespace(XPathNamespaceScope scope) { return(navigator.MoveToNextNamespace(scope)); }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { logger.Trace("MoveToNextNamespace"); return(false); }
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) => default; // 0x00000001806134E0-0x0000000180613780 public override bool MoveToNextNamespace(XPathNamespaceScope scope) => default; // 0x0000000180613780-0x0000000180613990
public override XPathNavigator Clone() => default; // 0x0000000180613360-0x0000000180613440 public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) => default; // 0x00000001806134E0-0x0000000180613780
//Moves to the next namespace node depending upon the namespace scope. public override bool MoveToNextNamespace( XPathNamespaceScope nsScope ) { //Navigator should be on a Namespace node when this is called. if ( ( _curNode.NodeType != XmlNodeType.Attribute ) || ( ! ( Ref.Equal(_curNode.NamespaceURI, XmlDocument.strReservedXmlns) ) ) ) return false; if( nsScope == XPathNamespaceScope.Local ) { XmlAttribute attr = _curNode as XmlAttribute; if( _curNode == null ) return false; _curNode = attr.OwnerElement; if( _curNode == null ) return false; //Navigator is no more in local scope if the following //condition is satisfied. if( _curNode != _parentOfNS ) return false; return MoveToNextLocalNamespace( _curNode, _attrInd ); } else if( nsScope == XPathNamespaceScope.ExcludeXml ) return MoveToNextNonXmlNamespace(); else if( nsScope == XPathNamespaceScope.All ) { XmlNode temp = ((XmlAttribute)_curNode).OwnerElement; if( temp == null ) return false; if( MoveToNextNonXmlNamespace() ) return true; _curNode = attrXmlNS; return true; } else return false; }
/// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToFirstNamespace1"]/*' /> public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { return(_xn.MoveToFirstNamespace(namespaceScope)); }
/// <summary> /// Position the navigator on the next namespace within the specified scope. If no matching namespace /// can be found, return false. /// </summary> public override bool MoveToNextNamespace(XPathNamespaceScope scope) { XPathNode[] page = _pageCurrent, pageParent; int idx = _idxCurrent, idxParent; // If current node is not a namespace node, return false if (page[idx].NodeType != XPathNodeType.Namespace) return false; while (true) { // Get next namespace sibling idx = page[idx].GetSibling(out page); // If there are no more nodes, return false if (idx == 0) return false; switch (scope) { case XPathNamespaceScope.Local: // Once parent changes, there are no longer any local namespaces idxParent = page[idx].GetParent(out pageParent); if (idxParent != _idxParent || (object)pageParent != (object)_pageParent) return false; break; case XPathNamespaceScope.ExcludeXml: // If node is xmlns:xml, then skip it if (page[idx].IsXmlNamespaceNode) continue; break; } // Found a matching next namespace node, so return it break; } _pageCurrent = page; _idxCurrent = idx; return true; }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) => _inner.MoveToNextNamespace(namespaceScope);
public override bool MoveToNextNamespace (XPathNamespaceScope scope) { if (attr == null) return false; for (XAttribute a = attr.NextAttribute; a != null; a = a.NextAttribute) if (a.IsNamespaceDeclaration) { attr = a; return true; } if (scope == XPathNamespaceScope.Local) return false; for (XElement el = ((XElement) attr.Parent).Parent; el != null; el = el.Parent) { foreach (XAttribute a in el.Attributes ()) if (a.IsNamespaceDeclaration) { attr = a; return true; } } if (scope != XPathNamespaceScope.All) return false; attr = attr_ns_xml; return true; }
/// <summary> /// See <see cref="XPathNavigator.MoveToNextNamespace(XPathNamespaceScope)"/>. /// </summary> public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { return(nav.MoveToNextNamespace(namespaceScope)); }
public override bool MoveToFirstNamespace ( XPathNamespaceScope namespaceScope) { if (!currentIsNode) return false; int cur = nodes [currentNode].FirstNamespace; return moveToSpecifiedNamespace (cur, namespaceScope); }
/// <summary> /// Copy the navigator subtree to the raw writer. /// </summary> private void CopyNode(XPathNavigator nav) { XPathNodeType nodeType; int iLevel = 0; while (true) { if (CopyShallowNode(nav)) { nodeType = nav.NodeType; if (nodeType == XPathNodeType.Element) { // Copy attributes if (nav.MoveToFirstAttribute()) { do { CopyShallowNode(nav); }while (nav.MoveToNextAttribute()); nav.MoveToParent(); } // Copy namespaces in document order (navigator returns them in reverse document order) XPathNamespaceScope nsScope = (iLevel == 0) ? XPathNamespaceScope.ExcludeXml : XPathNamespaceScope.Local; if (nav.MoveToFirstNamespace(nsScope)) { CopyNamespaces(nav, nsScope); nav.MoveToParent(); } _xwrt.StartElementContent(); } // If children exist, move down to next level if (nav.MoveToFirstChild()) { iLevel++; continue; } else { // EndElement if (nav.NodeType == XPathNodeType.Element) { _xwrt.WriteEndElement(nav.Prefix, nav.LocalName, nav.NamespaceURI); } } } // No children while (true) { if (iLevel == 0) { // The entire subtree has been copied return; } if (nav.MoveToNext()) { // Found a sibling, so break to outer loop break; } // No siblings, so move up to previous level iLevel--; nav.MoveToParent(); // EndElement if (nav.NodeType == XPathNodeType.Element) { _xwrt.WriteFullEndElement(nav.Prefix, nav.LocalName, nav.NamespaceURI); } } } }
public override bool MoveToNextNamespace(XPathNamespaceScope scope) { return false; }
/// <summary>See <see cref="XPathNavigator.MoveToFirstNamespace"/></summary> public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { return(_state.AtRoot? false: _state.Navigator.MoveToFirstNamespace(namespaceScope)); }
public override bool MoveToFirstNamespace(XPathNamespaceScope scope) { XmlElement element = _source as XmlElement; if (element == null) { return false; } XmlAttributeCollection attributes; int index = Int32.MaxValue; switch (scope) { case XPathNamespaceScope.Local: if (!element.HasAttributes) { return false; } attributes = element.Attributes; if (!MoveToFirstNamespaceLocal(attributes, ref index)) { return false; } _source = attributes[index]; _attributeIndex = index; _namespaceParent = element; break; case XPathNamespaceScope.ExcludeXml: attributes = element.Attributes; if (!MoveToFirstNamespaceGlobal(ref attributes, ref index, element)) { return false; } XmlAttribute attribute = attributes[index]; while (Ref.Equal(attribute.LocalName, XmlConst.NsXml)) { if (!MoveToNextNamespaceGlobal(ref attributes, ref index, element)) { return false; } attribute = attributes[index]; } _source = attribute; _attributeIndex = index; _namespaceParent = element; break; case XPathNamespaceScope.All: attributes = element.Attributes; if (!MoveToFirstNamespaceGlobal(ref attributes, ref index, element)) { _source = _document.GetNamespaceXml(); // attributeIndex = 0; } else { _source = attributes[index]; _attributeIndex = index; } _namespaceParent = element; break; default: Debug.Assert(false); return false; } return true; }
/// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToNextNamespace1"]/*' /> public abstract bool MoveToNextNamespace(XPathNamespaceScope namespaceScope);
/// <summary> /// Copy all or some (which depends on nsScope) of the namespaces on the navigator's current node to the /// raw writer. /// </summary> private void CopyNamespaces(XPathNavigator nav, XPathNamespaceScope nsScope) { string prefix = nav.LocalName; string ns = nav.Value; if (nav.MoveToNextNamespace(nsScope)) { CopyNamespaces(nav, nsScope); } this.xwrt.WriteNamespaceDeclaration(prefix, ns); }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { throw new NotSupportedException(); }
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { //StreamUtil.WriteText("I:\\debug.txt","进到 MoveToFirstNamespace()\r\n"); if (!(this.m_navigatorState.CurItem is ElementItem)) return false; ElementItem element = (ElementItem)this.m_navigatorState.CurItem; ItemList namespaceList = element.NamespaceList; if (namespaceList.Count > 0) { this.m_navigatorState.CurItem = namespaceList[0]; return true; } return false; }
public override bool MoveToFirstNamespace(XPathNamespaceScope scope) { this.InternalTrace(null); return(false); }
//Moves to the first namespace node depending upon the namespace scope. public override bool MoveToFirstNamespace( XPathNamespaceScope nsScope ) { if( nsScope == XPathNamespaceScope.Local ) { XmlElement _parentOfNS = _curNode as XmlElement; if( _parentOfNS == null ) return false; if( MoveToFirstLocalNamespace( _curNode ) ) return true; else { _parentOfNS = null; return false; } } else if( nsScope == XPathNamespaceScope.ExcludeXml ) return MoveToFirstNonXmlNamespace(); else if( nsScope == XPathNamespaceScope.All ) { _parentOfNS = _curNode as XmlElement; XmlElement cache = _parentOfNS; if( _parentOfNS == null ) return false; if( MoveToFirstNonXmlNamespace() ) return true; _parentOfNS = cache; _curNode = attrXmlNS; return true; } else return false; }
/// <summary> /// See <see cref="XPathNavigator.MoveToNextNamespace(XPathNamespaceScope)"/>. /// </summary> public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { return(AtRoot ? false : _navigator.MoveToNextNamespace(namespaceScope)); }
/// <summary> /// Position the navigator on the namespace within the specified scope. If no matching namespace /// can be found, return false. /// </summary> public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { XPathNode[] page; int idx; if (namespaceScope == XPathNamespaceScope.Local) { // Get local namespaces only idx = XPathNodeHelper.GetLocalNamespaces(_pageCurrent, _idxCurrent, out page); } else { // Get all in-scope namespaces idx = XPathNodeHelper.GetInScopeNamespaces(_pageCurrent, _idxCurrent, out page); } while (idx != 0) { // Don't include the xmlns:xml namespace node if scope is ExcludeXml if (namespaceScope != XPathNamespaceScope.ExcludeXml || !page[idx].IsXmlNamespaceNode) { _pageParent = _pageCurrent; _idxParent = _idxCurrent; _pageCurrent = page; _idxCurrent = idx; return true; } // Skip past xmlns:xml idx = page[idx].GetSibling(out page); } return false; }
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { return(false); }
public override bool MoveToFirstNamespace (XPathNamespaceScope namespaceScope) { if (NodeType != XPathNodeType.Element) return false; XmlElement el = node as XmlElement; do { if (el.HasAttributes) { for (int i = 0; i < el.Attributes.Count; i++) { XmlAttribute attr = el.Attributes [i]; if (attr.NamespaceURI == Xmlns) { if (CheckNsNameAppearance (attr.Name, attr.Value)) continue; NsNode = attr; return true; } } } if (namespaceScope == XPathNamespaceScope.Local) return false; el = GetParentNode (el) as XmlElement; } while (el != null); if (namespaceScope == XPathNamespaceScope.All) { if (CheckNsNameAppearance (Document.NsNodeXml.Name, Document.NsNodeXml.Value)) return false; NsNode = Document.NsNodeXml; return true; } else return false; }
public override bool MoveToNextNamespace(XPathNamespaceScope scope) { return(false); }
public override bool MoveToFirstNamespace (XPathNamespaceScope scope) { for (XElement el = node as XElement; el != null; el = el.Parent) { foreach (XAttribute a in el.Attributes ()) if (a.IsNamespaceDeclaration) { attr = a; return true; } if (scope == XPathNamespaceScope.Local) return false; } if (scope != XPathNamespaceScope.All) return false; attr = attr_ns_xml; return true; }
/// <summary> /// Moves the XPathNavigator to the next namespace node. /// Always returns falsefor the HtmlNavigator implementation. /// </summary> /// <param name="scope">An XPathNamespaceScope value describing the namespace scope.</param> /// <returns>Always returns false for the HtmlNavigator implementation.</returns> public override bool MoveToNextNamespace(XPathNamespaceScope scope) { InternalTrace(null); return(false); }
public override bool MoveToNextNamespace (XPathNamespaceScope scope) { return navigator.MoveToNextNamespace (scope); }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { if (NsNode == Document.NsNodeXml) { // Current namespace is "xml", so there should be no more namespace nodes. return(false); } if (NsNode == null) { return(false); } // Get current attribute's position. int pos = 0; XmlElement owner = ((XmlAttribute)NsNode).OwnerElement; if (owner == null) { return(false); } int count = owner.Attributes.Count; for (; pos < count; pos++) { if (owner.Attributes [pos] == NsNode) { break; } } if (pos == count) { return(false); // Where is current attribute? Maybe removed. } // Find next namespace from the same element as current ns node. for (pos++; pos < count; pos++) { if (owner.Attributes [pos].NamespaceURI == Xmlns) { XmlAttribute a = owner.Attributes [pos]; if (CheckNsNameAppearance(a.Name, a.Value)) { continue; } NsNode = a; return(true); } } // If not found more, then find from ancestors. // But if scope is Local, then it returns false here. if (namespaceScope == XPathNamespaceScope.Local) { return(false); } owner = GetParentNode(owner) as XmlElement; while (owner != null) { if (owner.HasAttributes) { for (int i = 0; i < owner.Attributes.Count; i++) { XmlAttribute attr = owner.Attributes [i]; if (attr.NamespaceURI == Xmlns) { if (CheckNsNameAppearance(attr.Name, attr.Value)) { continue; } NsNode = attr; return(true); } } } owner = GetParentNode(owner) as XmlElement; } if (namespaceScope == XPathNamespaceScope.All) { if (CheckNsNameAppearance(Document.NsNodeXml.Name, Document.NsNodeXml.Value)) { return(false); } NsNode = Document.NsNodeXml; return(true); } return(false); }
private bool moveToSpecifiedNamespace (int cur, XPathNamespaceScope namespaceScope) { if (cur == 0) return false; if (namespaceScope == XPathNamespaceScope.Local && namespaces [cur].DeclaredElement != currentNode) return false; if (namespaceScope != XPathNamespaceScope.All && namespaces [cur].Namespace == XmlNamespaces.XML) return false; if (cur != 0) { moveToNamespace (cur); return true; } else return false; }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { return _adapter.MoveToNextNamespace(namespaceScope); }
public override bool MoveToNextNamespace ( XPathNamespaceScope namespaceScope) { if (currentIsAttr || currentIsNode) return false; int cur = namespaces [currentNs].NextNamespace; return moveToSpecifiedNamespace (cur, namespaceScope); }
//Caller( DataDocumentXPathNavigator will make sure that the node is at the right position for this call ) internal bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { //Debug.WriteLineIf( XmlTrace.traceXPathNodePointerFunctions.Enabled, "XPathNodePointer:MoveToFirstNamespace(namespaceScope)"); RealFoliate(); _parentOfNS = this._node as XmlBoundElement; //only need to check with _node, even if _column is not null and its mapping type is element, it can't have attributes if ( _parentOfNS == null ) return false; XmlNode node = this._node; XmlBoundElement be = null; while ( node != null ) { be = node as XmlBoundElement; if ( MoveToNextNamespace( be, null, null ) ) return true; //didn't find it if ( namespaceScope == XPathNamespaceScope.Local ) goto labelNoNS; //try the next element anccestor. do { node = node.ParentNode; } while ( node != null && node.NodeType != XmlNodeType.Element ); } if ( namespaceScope == XPathNamespaceScope.All ) { MoveTo( this._doc.attrXml, null, false ); return true; } labelNoNS: //didn't find one namespace node _parentOfNS = null; return false; }
/// <summary> /// Moves the XPathNavigator to the next namespace node. /// Always returns falsefor the HtmlNavigator implementation. /// </summary> /// <param name="scope">An XPathNamespaceScope value describing the namespace scope.</param> /// <returns>Always returns false for the HtmlNavigator implementation.</returns> public override bool MoveToNextNamespace(XPathNamespaceScope scope) { InternalTrace(null); return false; }
//Caller( DataDocumentXPathNavigator will make sure that the node is at the right position for this call ) internal bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { //Debug.WriteLineIf( XmlTrace.traceXPathNodePointerFunctions.Enabled, "XPathNodePointer:MoveToNextNamespace(namespaceScope)"); RealFoliate(); Debug.Assert( _parentOfNS != null ); XmlNode node = this._node; //first check within the same boundelement if ( this._column != null ) { Debug.Assert( this._column.Namespace == s_strReservedXmlns ); if ( namespaceScope == XPathNamespaceScope.Local && _parentOfNS != this._node ) //already outside scope return false; XmlBoundElement be = this._node as XmlBoundElement; Debug.Assert( be != null ); DataRow curRow = be.Row; Debug.Assert( curRow != null ); DataColumn curCol = PreviousColumn( curRow, this._column, true ); while ( curCol != null ) { if ( curCol.Namespace == s_strReservedXmlns ) { MoveTo( be, curCol, false ); return true; } curCol = PreviousColumn( curRow, curCol, true ); } //didn't find it in this loop if ( namespaceScope == XPathNamespaceScope.Local ) return false; //try its ancesstor do { node = node.ParentNode; } while ( node != null && node.NodeType != XmlNodeType.Element ); } else if ( this._node.NodeType == XmlNodeType.Attribute ) { XmlAttribute attr = (XmlAttribute)(this._node); Debug.Assert( attr != null ); node = attr.OwnerElement; if ( node == null ) return false; if ( namespaceScope == XPathNamespaceScope.Local && _parentOfNS != node ) //already outside scope return false; if ( MoveToNextNamespace( (XmlBoundElement)node, null, (XmlAttribute)attr ) ) return true; //didn't find it if ( namespaceScope == XPathNamespaceScope.Local ) return false; do { node = node.ParentNode; } while ( node != null && node.NodeType != XmlNodeType.Element ); } // till now, node should be the next accesstor (bound) element of the element parent of current namespace node (attribute or data column) while ( node != null ) { //try the namespace attributes from the same element XmlBoundElement be = node as XmlBoundElement; if ( MoveToNextNamespace( be, null, null ) ) return true; //no more namespace attribute under the same element do { node = node.ParentNode; } while ( node != null && node.NodeType == XmlNodeType.Element ); } //didn't find the next namespace, thus return if ( namespaceScope == XPathNamespaceScope.All ) { MoveTo( this._doc.attrXml, null, false ); return true; } return false; }
/// <summary> /// See <see cref="XPathNavigator.MoveToNextNamespace"/>. /// </summary> public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { return AtRoot ? false : _navigator.MoveToNextNamespace(namespaceScope); }
/// <summary> /// Copy all namespaces of the specified type (in-scope, exclude-xml, local) in document order to output. /// </summary> private void CopyNamespaces(XPathNavigator navigator, XPathNamespaceScope nsScope) { Debug.Assert(navigator.NodeType == XPathNodeType.Element, "Only elements have namespaces to copy"); // Default namespace undeclaration isn't included in navigator's namespace list, so add it now if (navigator.NamespaceURI.Length == 0) { Debug.Assert(navigator.LocalName.Length != 0, "xmlns:foo='' isn't allowed"); WriteNamespaceDeclarationUnchecked(string.Empty, string.Empty); } // Since the namespace list is arranged in reverse-document order, recursively reverse it. if (navigator.MoveToFirstNamespace(nsScope)) { CopyNamespacesHelper(navigator, nsScope); navigator.MoveToParent(); } }
public abstract bool MoveToNextNamespace (XPathNamespaceScope namespaceScope);
/// <summary> /// Recursive helper function that reverses order of the namespaces retrieved by MoveToFirstNamespace and /// MoveToNextNamespace. /// </summary> private void CopyNamespacesHelper(XPathNavigator navigator, XPathNamespaceScope nsScope) { string prefix = navigator.LocalName; string ns = navigator.Value; if (navigator.MoveToNextNamespace(nsScope)) CopyNamespacesHelper(navigator, nsScope); // No possibility for conflict, since we're copying namespaces from well-formed element WriteNamespaceDeclarationUnchecked(prefix, ns); }
public override bool MoveToNextNamespace(XPathNamespaceScope scope) { XmlAttribute attribute = _source as XmlAttribute; if (attribute == null || !attribute.IsNamespace()) { return false; } XmlAttributeCollection attributes; int index = _attributeIndex; if (!CheckAttributePosition(attribute, out attributes, index) && !ResetAttributePosition(attribute, attributes, out index)) { return false; } Debug.Assert(_namespaceParent != null); switch (scope) { case XPathNamespaceScope.Local: if (attribute.OwnerElement != _namespaceParent) { return false; } if (!MoveToNextNamespaceLocal(attributes, ref index)) { return false; } _source = attributes[index]; _attributeIndex = index; break; case XPathNamespaceScope.ExcludeXml: string localName; do { if (!MoveToNextNamespaceGlobal(ref attributes, ref index, attribute.OwnerElement)) { return false; } attribute = attributes[index]; localName = attribute.LocalName; } while (PathHasDuplicateNamespace(attribute.OwnerElement, _namespaceParent, localName) || Ref.Equal(localName, XmlConst.NsXml)); _source = attribute; _attributeIndex = index; break; case XPathNamespaceScope.All: do { if (!MoveToNextNamespaceGlobal(ref attributes, ref index, attribute.OwnerElement)) { if (PathHasDuplicateNamespace(null, _namespaceParent, XmlConst.NsXml)) { return false; } else { _source = _document.GetNamespaceXml(); // attributeIndex = 0; return true; } } attribute = attributes[index]; } while (PathHasDuplicateNamespace(attribute.OwnerElement, _namespaceParent, attribute.LocalName)); _source = attribute; _attributeIndex = index; break; default: Debug.Assert(false); return false; } return true; }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { // TODO: Need to figure out what this is doing return(false); }