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


C# XPathNavigator.GetNamespace方法代码示例

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


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

示例1: GetXmlType

		public XmlQualifiedName GetXmlType(XPathNavigator source)
		{
			var qualifiedType = source.GetAttribute("type", Xsi);
			if (string.IsNullOrEmpty(qualifiedType) == false)
			{
				string name, namespaceUri = null;
				var prefix = SplitQualifiedName(qualifiedType, out name);
				if (prefix != null)
					namespaceUri = source.GetNamespace(prefix);
				return new XmlQualifiedName(name, namespaceUri);
			}
			return null;
		}
开发者ID:n2cms,项目名称:Castle.Core,代码行数:13,代码来源:XPathContext.cs

示例2: GetAttribute

 public override string GetAttribute( string localName, string namespaceURI ) {
     if ( null == localName )
         throw new ArgumentNullException("localName");
     // reader allows calling GetAttribute, even when positioned inside attributes
     XPathNavigator nav = this.nav;
     switch (nav.NodeType) {
         case XPathNodeType.Element:
             break;
         case XPathNodeType.Attribute:
             nav = nav.Clone();
             if (!nav.MoveToParent())
                 return null;
             break;
         default:
             return null;
     }
     // are they really looking for a namespace-decl?
     if( namespaceURI == XmlReservedNs.NsXmlNs ) {
         if (localName == "xmlns")
             localName = string.Empty;
         return nav.GetNamespace( localName );
     }
     if ( null == namespaceURI )
         namespaceURI = string.Empty;
     // We need to clone the navigator and move the clone to the attribute to see whether the attribute exists, 
     // because XPathNavigator.GetAttribute return string.Empty for both when the the attribute is not there or when 
     // it has an empty value. XmlReader.GetAttribute must return null if the attribute does not exist.
     if ((object)nav == (object)this.nav)
         nav = nav.Clone();
     if ( nav.MoveToAttribute( localName, namespaceURI ) ) {
         return nav.Value;
     }
     else {
         return null;
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:36,代码来源:xpathnavigatorreader.cs

示例3: CreateNamespace

		public string CreateNamespace(string prefix, string namespaceUri, XPathNavigator source)
		{
			if (string.IsNullOrEmpty(namespaceUri) == false)
			{
				source = source.Clone();
				source.MoveToRoot();
				source.MoveToChild(XPathNodeType.Element);

				if (string.IsNullOrEmpty(prefix))
					prefix = AddNamespace(namespaceUri);

				var existing = source.GetNamespace(prefix);
				if (existing == namespaceUri) return prefix;
				if (string.IsNullOrEmpty(existing) == false) return null;

				source.CreateAttribute("xmlns", prefix, "", namespaceUri);
			}
			return prefix;
		}
开发者ID:n2cms,项目名称:Castle.Core,代码行数:19,代码来源:XPathContext.cs

示例4: GetNamespaceConsistentTree

		private void GetNamespaceConsistentTree (XPathNavigator nav)
		{
			nav.MoveToFirstChild ();
			nav.MoveToFirstChild ();
			nav.MoveToNext ();
			Assert.AreEqual ("ns1", nav.GetNamespace (""), "#1." + nav.GetType ());
			nav.MoveToNext ();
			nav.MoveToNext ();
			Assert.AreEqual ("", nav.GetNamespace (""), "#2." + nav.GetType ());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:10,代码来源:XPathNavigatorCommonTests.cs

示例5: TryParseDataTypeReference

 public static bool TryParseDataTypeReference(string typeStr, XPathNavigator dataTypeElementNav,
     out string schemaURI, out string dataTypeName)
 {
   schemaURI = null;
   dataTypeName = null;
   int index = typeStr.LastIndexOf(':');
   if (index == -1)
     return false;
   string prefix = typeStr.Substring(0, index);
   dataTypeName = typeStr.Substring(index + 1);
   schemaURI = prefix.StartsWith("urn:") ? prefix : dataTypeElementNav.GetNamespace(prefix);
   return true;
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:13,代码来源:ParserHelper.cs

示例6: ParseMappedPrefixes

		private QName [] ParseMappedPrefixes (string list, XPathNavigator nav)
		{
			if (list == null)
				return null;
			ArrayList al = new ArrayList ();
			foreach (string entry in list.Split (XmlChar.WhitespaceChars)) {
				if (entry.Length == 0)
					continue;
				if (entry == "#default")
					al.Add (new QName (String.Empty, String.Empty));
				else {
					string entryNS = nav.GetNamespace (entry);
					if (entryNS != String.Empty)
						al.Add (new QName (entry, entryNS));
				}
			}
			return (QName []) al.ToArray (typeof (QName));
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:18,代码来源:XslStylesheet.cs

示例7: FromString

		public static QName FromString (string name, XPathNavigator current, bool useDefaultXmlns)
		{
			if (current.NodeType == XPathNodeType.Attribute)
				(current = current.Clone ()).MoveToParent ();
			
			int colon = name.IndexOf (':');
			if (colon > 0)
				return new QName (name.Substring (colon+ 1), current.GetNamespace (name.Substring (0, colon)));
			else if (colon < 0)
				return new QName (name, useDefaultXmlns ? current.GetNamespace (String.Empty) : "");
			else
				throw new ArgumentException ("Invalid name: " + name);
		}
开发者ID:GirlD,项目名称:mono,代码行数:13,代码来源:Compiler.cs

示例8: GetAttribute

        public override string GetAttribute(string localName, string namespaceURI)
        {
            if (localName == null)
            {
                throw new ArgumentNullException("localName");
            }
            XPathNavigator nav = this.nav;
            switch (nav.NodeType)
            {
                case XPathNodeType.Element:
                    break;

                case XPathNodeType.Attribute:
                    nav = nav.Clone();
                    if (nav.MoveToParent())
                    {
                        break;
                    }
                    return null;

                default:
                    return null;
            }
            if (namespaceURI == "http://www.w3.org/2000/xmlns/")
            {
                if (localName == "xmlns")
                {
                    localName = string.Empty;
                }
                return nav.GetNamespace(localName);
            }
            if (namespaceURI == null)
            {
                namespaceURI = string.Empty;
            }
            if (nav == this.nav)
            {
                nav = nav.Clone();
            }
            if (nav.MoveToAttribute(localName, namespaceURI))
            {
                return nav.Value;
            }
            return null;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:45,代码来源:XPathNavigatorReader.cs

示例9: Parse

        public MeshElement Parse(XPathNavigator nav, string geomName, bool generateTangents = false)
        {
            Name = geomName;
            nsName = nav.GetNamespace("c");

            var mesh = nav.SelectSingleNode("c:mesh", nsManager);
            if (mesh == null)
                throw new GeometryParserException("Geometry does not contain mesh!");

            ParseMesh(mesh);

            CreateArrays(generateTangents);

            MeshElement retMesh = new MeshElement(_vertexDeclaration, vertexData, indexData);
            return retMesh;
        }
开发者ID:slicedpan,项目名称:ModelMesh,代码行数:16,代码来源:GeometryParser.cs

示例10: ParseSource

        private void ParseSource(XPathNavigator nav)
        {
            string sourceName = nav.GetAttribute("id", nav.GetNamespace("c"));
            Console.WriteLine("found source: " + sourceName);
            var arrayNode = nav.SelectSingleNode("c:float_array", nsManager);
            int arrayCount;
            if (!int.TryParse(arrayNode.GetAttribute("count", arrayNode.GetNamespace("c")), out arrayCount))
                throw new GeometryParserException("could not parse source: " + sourceName + " array");
            sources.Add(sourceName, new Source(new float[arrayCount]));
            string[] parts = arrayNode.InnerXml.Split(' ');

            for (int i = 0; i < arrayCount; ++i)
            {
                float fVal;
                if (!float.TryParse(parts[i], out fVal))
                    throw new GeometryParserException("could not parse source: " + sourceName + " array, element: " + i);
                sources[sourceName][i] = fVal;
            }

            var accessorNode = nav.SelectSingleNode("c:technique_common/c:accessor", nsManager);
            int.TryParse(accessorNode.GetAttribute("stride", nsName), out sources[sourceName].stride);
        }
开发者ID:slicedpan,项目名称:ModelMesh,代码行数:22,代码来源:GeometryParser.cs


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