當前位置: 首頁>>代碼示例>>C#>>正文


C# IXmlNamespaceResolver.LookupNamespace方法代碼示例

本文整理匯總了C#中System.Xml.IXmlNamespaceResolver.LookupNamespace方法的典型用法代碼示例。如果您正苦於以下問題:C# IXmlNamespaceResolver.LookupNamespace方法的具體用法?C# IXmlNamespaceResolver.LookupNamespace怎麽用?C# IXmlNamespaceResolver.LookupNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.IXmlNamespaceResolver的用法示例。


在下文中一共展示了IXmlNamespaceResolver.LookupNamespace方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WriteNamespaces

		public void WriteNamespaces (string defaultNamespace, NSResolver nsmgr, bool isData)
		{
			if (defaultNamespace == null)
				defaultNamespace = String.Empty;

			if (defaultNamespace.Length > 0)
				w.WriteLine ("default namespace = {0}",
					defaultNamespace);

			if (nsmgr != null) {
#if NET_2_0
				foreach (string s in nsmgr.GetNamespacesInScope (
					XmlNamespaceScope.All).Keys) {
#else
				foreach (string s in nsmgr) {
#endif
					switch (s) {
					case "xml":
					case "xmlns":
						continue;
					case "":
						if (defaultNamespace.Length > 0)
							w.WriteLine ("default namespace = '{0}'",
								nsmgr.LookupNamespace (s).Replace ('\'', '\"'));
						break;
					default:
						w.WriteLine ("{2} {0} = '{1}'",
							s,
							nsmgr.LookupNamespace (s).Replace ('\'', '\"'),
							isData ? "datatypes" : "namespace");
						break;
					}
				}
			}
			w.WriteLine ();
		}

		#region Elements
		// Note that it might not be used directly when a grammar
		// contains more than one "start" (compact syntax does not
		// support "combine" attribute).
		public void WriteStart (RelaxngStart start)
		{
			w.Write ("start");
			if (start.Combine == null)
				w.Write (" = ");
			else
				w.Write (start.Combine.Trim () == "interleave" ?
					" &= " : " |= ");
			start.Pattern.WriteRnc (this);
			w.WriteLine ();
		}
開發者ID:runefs,項目名稱:Marvin,代碼行數:52,代碼來源:RncWriter.cs

示例2: GetInfo

		public override void GetInfo (out string name, out string ns, out XPathNodeType nodetype, NSResolver nsm)
		{
			// must be the correct node type
			nodetype = _axis.NodeType;
			
			if (_name.Name != "")
				name = _name.Name;
			else
				name = null;
			ns = "";
			if (nsm != null && _name.Namespace != "") {
				if (resolvedName)
					ns = _name.Namespace;
				else
					ns = nsm.LookupNamespace (_name.Namespace);	// TODO: check to see if this returns null or ""
				if (ns == null)
					throw new XPathException ("Invalid namespace prefix: "+_name.Namespace);
			}
		}
開發者ID:nobled,項目名稱:mono,代碼行數:19,代碼來源:Expression.cs

示例3: Match

		public override bool Match (NSResolver nsm, XPathNavigator nav)
		{
			// must be the correct node type
			if (nav.NodeType != _axis.NodeType)
				return false;

			if (_name.Name != "")
			{
				// test the local part of the name first
				if (_name.Name != nav.LocalName)
					return false;
			}

			// get the prefix for the given name
			String strURI1 = "";
			if (_name.Namespace != "")
			{
				if (resolvedName)
					strURI1 = _name.Namespace;
				else if (nsm != null)
					strURI1 = nsm.LookupNamespace (_name.Namespace);
				if (strURI1 == null)
					throw new XPathException ("Invalid namespace prefix: "+_name.Namespace);
			}

			// test the prefixes
			return strURI1 == nav.NamespaceURI;
		}
開發者ID:nobled,項目名稱:mono,代碼行數:28,代碼來源:Expression.cs

示例4: WriteNamespaces

		public void WriteNamespaces (string defaultNamespace, NSResolver nsmgr, bool isData)
		{
			if (defaultNamespace == null)
				defaultNamespace = String.Empty;

			if (defaultNamespace.Length > 0)
				w.WriteLine ("default namespace = {0}",
					defaultNamespace);

			if (nsmgr != null) {
				foreach (string s in nsmgr.GetNamespacesInScope (
					XmlNamespaceScope.All).Keys) {
					switch (s) {
					case "xml":
					case "xmlns":
						continue;
					case "":
						if (defaultNamespace.Length > 0)
							w.WriteLine ("default namespace = '{0}'",
								nsmgr.LookupNamespace (s).Replace ('\'', '\"'));
						break;
					default:
						w.WriteLine ("{2} {0} = '{1}'",
							s,
							nsmgr.LookupNamespace (s).Replace ('\'', '\"'),
							isData ? "datatypes" : "namespace");
						break;
					}
				}
			}
			w.WriteLine ();
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:32,代碼來源:RncWriter.cs

示例5: GetInfo

		public override void GetInfo (out string name, out string ns, out XPathNodeType nodetype, NSResolver nsm)
		{
			// must be the correct node type
			nodetype = _axis.NodeType;
			
			if (_name.Name != "")
				name = _name.Name;
			else
				name = null;
			ns = "";
			if (nsm != null && _name.Namespace != "") {
				if (resolvedName)
					ns = _name.Namespace;
				else
// We still need to have such tricky switch, because the behavior is 
// inconsistent between .NET 1.x and 2.0 when the argument is not
// atomic string.
#if NET_2_0
					ns = nsm.LookupNamespace (_name.Namespace);	// TODO: check to see if this returns null or ""
#else
					ns = nsm.LookupNamespace (_name.Namespace, false);	// TODO: check to see if this returns null or ""
#endif
				if (ns == null)
					throw new XPathException ("Invalid namespace prefix: "+_name.Namespace);
			}
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:26,代碼來源:Expression.cs

示例6: Match

		public override bool Match (NSResolver nsm, XPathNavigator nav)
		{
			// must be the correct node type
			if (nav.NodeType != _axis.NodeType)
				return false;

			if (_name.Name != "")
			{
				// test the local part of the name first
				if (_name.Name != nav.LocalName)
					return false;
			}

			// get the prefix for the given name
			String strURI1 = "";
			if (_name.Namespace != "")
			{
				if (resolvedName)
					strURI1 = _name.Namespace;
				else if (nsm != null)
// We still need to have such tricky switch, because the behavior is 
// inconsistent between .NET 1.x and 2.0 when the argument is not
// atomic string.
#if NET_2_0
					strURI1 = nsm.LookupNamespace (_name.Namespace);
#else
					strURI1 = nsm.LookupNamespace (_name.Namespace, false);
#endif
				if (strURI1 == null)
					throw new XPathException ("Invalid namespace prefix: "+_name.Namespace);
			}

			// test the prefixes
			return strURI1 == nav.NamespaceURI;
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:35,代碼來源:Expression.cs


注:本文中的System.Xml.IXmlNamespaceResolver.LookupNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。