当前位置: 首页>>代码示例>>C#>>正文


C# XPathNavigator.MoveToNextNamespace方法代码示例

本文整理汇总了C#中System.Xml.XPath.XPathNavigator.MoveToNextNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.MoveToNextNamespace方法的具体用法?C# XPathNavigator.MoveToNextNamespace怎么用?C# XPathNavigator.MoveToNextNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XPath.XPathNavigator的用法示例。


在下文中一共展示了XPathNavigator.MoveToNextNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteLocalNamespaces

        private static void WriteLocalNamespaces(this XmlWriter writer, XPathNavigator nsNav)
        {
            string prefix = nsNav.LocalName;
            string ns = nsNav.Value;

            if (nsNav.MoveToNextNamespace(XPathNamespaceScope.Local))
            {
                writer.WriteLocalNamespaces(nsNav);
            }

            if (prefix.Length == 0)
            {
                writer.WriteAttributeString(string.Empty, "xmlns", XmlConst.ReservedNsXmlNs, ns);
            }
            else
            {
                writer.WriteAttributeString("xmlns", prefix, XmlConst.ReservedNsXmlNs, ns);
            }
        }
开发者ID:svcgany1,项目名称:corefx,代码行数:19,代码来源:XmlWriterExtensions.cs

示例2: XmlNamespaceNode

		private void XmlNamespaceNode (XPathNavigator nav)
		{
			string xhtml = "http://www.w3.org/1999/xhtml";
			string xmlNS = "http://www.w3.org/XML/1998/namespace";
			nav.MoveToFirstChild ();
			AssertNavigator ("#1", nav, XPathNodeType.Element,
				"", "html", xhtml, "html", "test.", false, true, false);
			Assert.IsTrue (nav.MoveToFirstNamespace (XPathNamespaceScope.Local));
			AssertNavigator ("#2", nav, XPathNodeType.Namespace,
				"", "", "", "", xhtml, false, false, false);

			// Test difference between Local, ExcludeXml and All.
			Assert.IsTrue (!nav.MoveToNextNamespace (XPathNamespaceScope.Local));
			Assert.IsTrue (!nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml));
			// LAMESPEC: MS.NET 1.0 XmlDocument seems to have some bugs around here.
			// see http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q316808
#if true
			Assert.IsTrue (nav.MoveToNextNamespace (XPathNamespaceScope.All));
			AssertNavigator ("#3", nav, XPathNodeType.Namespace,
				"", "xml", "", "xml", xmlNS, false, false, false);
			Assert.IsTrue (!nav.MoveToNextNamespace (XPathNamespaceScope.All));
#endif
			// Test to check if MoveToRoot() resets Namespace node status.
			nav.MoveToRoot ();
			AssertNavigator ("#4", nav, XPathNodeType.Root, "", "", "", "", "test.", false, true, false);
			nav.MoveToFirstChild ();

			// Test without XPathNamespaceScope argument.
			Assert.IsTrue (nav.MoveToFirstNamespace ());
			Assert.IsTrue (nav.MoveToNextNamespace ());
			AssertNavigator ("#5", nav, XPathNodeType.Namespace,
				"", "xml", "", "xml", xmlNS, false, false, false);

			// Test MoveToParent()
			Assert.IsTrue (nav.MoveToParent ());
			AssertNavigator ("#6", nav, XPathNodeType.Element,
				"", "html", xhtml, "html", "test.", false, true, false);

			nav.MoveToFirstChild ();	// body
			// Test difference between Local and ExcludeXml
			Assert.IsTrue (!nav.MoveToFirstNamespace (XPathNamespaceScope.Local), "Local should fail");
			Assert.IsTrue (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml), "ExcludeXml should succeed");
			AssertNavigator ("#7", nav, XPathNodeType.Namespace,
				"", "", "", "", xhtml, false, false, false);

			Assert.IsTrue (nav.MoveToNextNamespace (XPathNamespaceScope.All));
			AssertNavigator ("#8", nav, XPathNodeType.Namespace,
				"", "xml", "", "xml", xmlNS, false, false, false);
			Assert.IsTrue (nav.MoveToParent ());
			AssertNavigator ("#9", nav, XPathNodeType.Element,
				"", "body", xhtml, "body", "test.", false, true, false);

			nav.MoveToRoot ();
			AssertNavigator ("#10", nav, XPathNodeType.Root, "", "", "", "", "test.", false, true, false);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:55,代码来源:XPathNavigatorCommonTests.cs

示例3: CompareSiblings

        private XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2)
        {
            int num = 0;
            switch (n1.NodeType)
            {
                case XPathNodeType.Attribute:
                    num++;
                    break;

                case XPathNodeType.Namespace:
                    break;

                default:
                    num += 2;
                    break;
            }
            switch (n2.NodeType)
            {
                case XPathNodeType.Attribute:
                    num--;
                    if (num == 0)
                    {
                        while (n1.MoveToNextAttribute())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;

                case XPathNodeType.Namespace:
                    if (num == 0)
                    {
                        while (n1.MoveToNextNamespace())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;

                default:
                    num -= 2;
                    if (num == 0)
                    {
                        while (n1.MoveToNext())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;
            }
            if (num >= 0)
            {
                return XmlNodeOrder.After;
            }
            return XmlNodeOrder.Before;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:65,代码来源:XPathNavigator.cs

示例4: WriteLocalNamespaces

        // Copy local namespaces on the navigator's current node to the raw writer. The namespaces are returned by the navigator in reversed order. 
        // The recursive call reverses them back.
        private void WriteLocalNamespaces(XPathNavigator nsNav)
        {
            string prefix = nsNav.LocalName;
            string ns = nsNav.Value;

            if (nsNav.MoveToNextNamespace(XPathNamespaceScope.Local))
            {
                WriteLocalNamespaces(nsNav);
            }

            if (prefix.Length == 0)
            {
                WriteAttributeString(string.Empty, "xmlns", XmlReservedNs.NsXmlNs, ns);
            }
            else
            {
                WriteAttributeString("xmlns", prefix, XmlReservedNs.NsXmlNs, ns);
            }
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:21,代码来源:XmlWriter.cs

示例5: WriteLocalNamespacesAsync

        // Copy local namespaces on the navigator's current node to the raw writer. The namespaces are returned by the navigator in reversed order. 
        // The recursive call reverses them back.
        private async Task WriteLocalNamespacesAsync(XPathNavigator nsNav) {
            string prefix = nsNav.LocalName;
            string ns = nsNav.Value;

            if (nsNav.MoveToNextNamespace(XPathNamespaceScope.Local)) {
                await WriteLocalNamespacesAsync(nsNav).ConfigureAwait(false);
            }

            if (prefix.Length == 0) {
                await WriteAttributeStringAsync(string.Empty, "xmlns", XmlReservedNs.NsXmlNs, ns).ConfigureAwait(false);
            }
            else {
                await WriteAttributeStringAsync("xmlns", prefix, XmlReservedNs.NsXmlNs, ns).ConfigureAwait(false);
            }
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:17,代码来源:XmlWriterAsync.cs

示例6: CopyNamespaces

        /// <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);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:14,代码来源:XmlSequenceWriter.cs

示例7: CopyNamespacesHelper

        /// <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);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:14,代码来源:XmlQueryOutput.cs

示例8: GetNamespaceByIndex

 private static string GetNamespaceByIndex(XPathNavigator nav, int index, out int count)
 {
     string str = nav.Value;
     string str2 = null;
     if (nav.MoveToNextNamespace(XPathNamespaceScope.Local))
     {
         str2 = GetNamespaceByIndex(nav, index, out count);
     }
     else
     {
         count = 0;
     }
     if (count == index)
     {
         str2 = str;
     }
     count++;
     return str2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:XPathNavigatorReader.cs

示例9: Create

        /// <summary>
        /// Initialize the NamespaceIterator.
        /// </summary>
        public void Create(XPathNavigator context) {
            // Push all of context's in-scope namespaces onto a stack in order to return them in document order
            // (MoveToXXXNamespace methods return namespaces in reverse document order)
            this.navStack.Reset();
            if (context.MoveToFirstNamespace(XPathNamespaceScope.All)) {
                do {
                    // Don't return the default namespace undeclaration
                    if (context.LocalName.Length != 0 || context.Value.Length != 0)
                        this.navStack.Push(context.Clone());
                }
                while (context.MoveToNextNamespace(XPathNamespaceScope.All));

                context.MoveToParent();
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:18,代码来源:ContentIterators.cs

示例10: WriteNode

		public virtual void WriteNode (XPathNavigator navigator, bool defattr)
		{
			if (navigator == null)
				throw new ArgumentNullException ("navigator");
			switch (navigator.NodeType) {
			case XPathNodeType.Attribute:
				// no operation
				break;
			case XPathNodeType.Namespace:
				// no operation
				break;
			case XPathNodeType.Text:
				WriteString (navigator.Value);
				break;
			case XPathNodeType.SignificantWhitespace:
				WriteWhitespace (navigator.Value);
				break;
			case XPathNodeType.Whitespace:
				WriteWhitespace (navigator.Value);
				break;
			case XPathNodeType.Comment:
				WriteComment (navigator.Value);
				break;
			case XPathNodeType.ProcessingInstruction:
				WriteProcessingInstruction (navigator.Name, navigator.Value);
				break;
			case XPathNodeType.Root:
				if (navigator.MoveToFirstChild ()) {
					do {
						WriteNode (navigator, defattr);
					} while (navigator.MoveToNext ());
					navigator.MoveToParent ();
				}
				break;
			case XPathNodeType.Element:
				WriteStartElement (navigator.Prefix, navigator.LocalName, navigator.NamespaceURI);
				if (navigator.MoveToFirstNamespace (XPathNamespaceScope.Local)) {
					do {
						if (defattr || navigator.SchemaInfo == null || navigator.SchemaInfo.IsDefault)
							WriteAttributeString (navigator.Prefix,
								navigator.LocalName == String.Empty ? "xmlns" : navigator.LocalName,
								"http://www.w3.org/2000/xmlns/",
								navigator.Value);
					} while (navigator.MoveToNextNamespace (XPathNamespaceScope.Local));
					navigator.MoveToParent ();
				}
				if (navigator.MoveToFirstAttribute ()) {
					do {
						if (defattr || navigator.SchemaInfo == null || navigator.SchemaInfo.IsDefault)
							WriteAttributeString (navigator.Prefix, navigator.LocalName, navigator.NamespaceURI, navigator.Value);

					} while (navigator.MoveToNextAttribute ());
					navigator.MoveToParent ();
				}
				if (navigator.MoveToFirstChild ()) {
					do {
						WriteNode (navigator, defattr);
					} while (navigator.MoveToNext ());
					navigator.MoveToParent ();
				}
				if (navigator.IsEmptyElement)
					WriteEndElement ();
				else
					WriteFullEndElement ();
				break;
			default:
				throw new NotSupportedException ();
			}
		}
开发者ID:afaerber,项目名称:mono,代码行数:69,代码来源:XmlWriter.cs

示例11: Compile

		public CompiledStylesheet Compile (XPathNavigator nav, XmlResolver res, Evidence evidence)
		{
			this.xpathParser = new XPathParser (this);
			this.patternParser = new XsltPatternParser (this);
			this.res = res;
			if (res == null)
				this.res = new XmlUrlResolver ();
			this.evidence = evidence;

			// reject empty document.
			if (nav.NodeType == XPathNodeType.Root && !nav.MoveToFirstChild ())
				throw new XsltCompileException ("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element", null, nav);
			while (nav.NodeType != XPathNodeType.Element) nav.MoveToNext();
			
			stylesheetVersion = nav.GetAttribute ("version", 
				(nav.NamespaceURI != XsltNamespace) ?
				XsltNamespace : String.Empty);
			outputs [""] = new XslOutput ("", stylesheetVersion);
				
			PushInputDocument (nav);
			if (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml))
			{
				do {
					nsMgr.AddNamespace (nav.LocalName, nav.Value);
				} while (nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml));
				nav.MoveToParent ();
			}
			try {
				rootStyle = new XslStylesheet ();
				rootStyle.Compile (this);
			} catch (XsltCompileException) {
				throw;
			} catch (Exception x) {
				throw new XsltCompileException ("XSLT compile error. " + x.Message, x,  Input);
			}
			
			return new CompiledStylesheet (rootStyle, globalVariables, attrSets, nsMgr, keys, outputs, decimalFormats, msScripts);
		}
开发者ID:GirlD,项目名称:mono,代码行数:38,代码来源:Compiler.cs

示例12: CopyNode

		void CopyNode (XslTransformProcessor p, XPathNavigator nav)
		{
			Outputter outputter = p.Out;
			switch (nav.NodeType) {
			case XPathNodeType.Root:
				XPathNodeIterator itr = nav.SelectChildren (XPathNodeType.All);
				while (itr.MoveNext ())
					CopyNode (p, itr.Current);
				break;
				
			case XPathNodeType.Element:
				bool isCData = p.InsideCDataElement;
				string prefix = nav.Prefix;
				string ns = nav.NamespaceURI;
				p.PushElementState (prefix, nav.LocalName, ns, false);
				outputter.WriteStartElement (prefix, nav.LocalName, ns);
				
				if (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml))
				{
					do {
						if (prefix == nav.Name)
							continue;
						if (nav.Name.Length == 0 && ns.Length == 0)
							continue;
						outputter.WriteNamespaceDecl (nav.Name, nav.Value);
					} while (nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml));
					nav.MoveToParent ();
				}
				
				if (nav.MoveToFirstAttribute())
				{
					do {
						outputter.WriteAttributeString (nav.Prefix, nav.LocalName, nav.NamespaceURI, nav.Value);
					} while (nav.MoveToNextAttribute ());
					nav.MoveToParent();
				}
				
				if (nav.MoveToFirstChild ()) {
					do {
						CopyNode (p, nav);
					} while (nav.MoveToNext ());
					nav.MoveToParent ();
				}

				if (nav.IsEmptyElement)
					outputter.WriteEndElement ();
				else
					outputter.WriteFullEndElement ();

				p.PopCDataState (isCData);
				break;
				
			case XPathNodeType.Namespace:
				if (nav.Name != p.XPathContext.ElementPrefix &&
					(p.XPathContext.ElementNamespace.Length > 0 || nav.Name.Length > 0))
					outputter.WriteNamespaceDecl (nav.Name, nav.Value);
				break;
			case XPathNodeType.Attribute:
				outputter.WriteAttributeString (nav.Prefix, nav.LocalName, nav.NamespaceURI, nav.Value);
				break;
			case XPathNodeType.Whitespace:
			case XPathNodeType.SignificantWhitespace:
				bool cdata = outputter.InsideCDataSection;
				outputter.InsideCDataSection = false;
				outputter.WriteString (nav.Value);
				outputter.InsideCDataSection = cdata;
				break;
			case XPathNodeType.Text:
				outputter.WriteString (nav.Value);
				break;
			case XPathNodeType.ProcessingInstruction:
				outputter.WriteProcessingInstruction (nav.Name, nav.Value);
				break;
			case XPathNodeType.Comment:
				outputter.WriteComment (nav.Value);
				break;
			}			
		}
开发者ID:kdoman21,项目名称:mono,代码行数:78,代码来源:XslCopyOf.cs

示例13: WriteLocalNamespaces

 private void WriteLocalNamespaces(XPathNavigator nsNav)
 {
     string localName = nsNav.LocalName;
     string str2 = nsNav.Value;
     if (nsNav.MoveToNextNamespace(XPathNamespaceScope.Local))
     {
         this.WriteLocalNamespaces(nsNav);
     }
     if (localName.Length == 0)
     {
         this.WriteAttributeString(string.Empty, "xmlns", "http://www.w3.org/2000/xmlns/", str2);
     }
     else
     {
         this.WriteAttributeString("xmlns", localName, "http://www.w3.org/2000/xmlns/", str2);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:XmlWriter.cs

示例14: CompareSiblings

 private XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2){
     bool attr1 = n1.NodeType == XPathNodeType.Attribute;
     bool attr2 = n2.NodeType == XPathNodeType.Attribute;
     bool ns1 = n1.NodeType == XPathNodeType.Namespace;
     bool ns2 = n2.NodeType == XPathNodeType.Namespace;
     if (! ns1 && ! ns2 && ! attr1 && ! attr2) {
         while (n1.MoveToNext()) {
             if (n1.IsSamePosition(n2))
                 return XmlNodeOrder.Before;
         }
         return XmlNodeOrder.After;
     }
     if (attr1 && attr2) {
         while (n1.MoveToNextAttribute()){
             if (n1.IsSamePosition(n2))
                 return XmlNodeOrder.Before;
         }
         return XmlNodeOrder.After;
     }
     if (attr1){
         return XmlNodeOrder.After;
     }
     if (attr2){
         return XmlNodeOrder.Before;
     }
     if (ns1 && ns2) {
         while (n1.MoveToNextNamespace()) {
             if (n1.IsSamePosition(n2))
                 return XmlNodeOrder.Before;
         }
         return XmlNodeOrder.After;
     }
     if (ns1){
         return XmlNodeOrder.After;
     }
     Debug.Assert(ns2);
     return XmlNodeOrder.Before;
 }
开发者ID:ArildF,项目名称:masters,代码行数:38,代码来源:xpathnavigator.cs

示例15: MoveToNamespaces

		private void MoveToNamespaces (XPathNavigator nav)
		{
			XPathNodeIterator iter = nav.Select ("//e");
			iter.MoveNext ();
			nav.MoveTo (iter.Current);
			Assert.AreEqual ("e", nav.Name, "#1");
			nav.MoveToFirstNamespace ();
			Assert.AreEqual ("x", nav.Name, "#2");
			nav.MoveToNextNamespace ();
			Assert.AreEqual ("xml", nav.Name, "#3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:XPathNavigatorCommonTests.cs


注:本文中的System.Xml.XPath.XPathNavigator.MoveToNextNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。