本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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 ());
}
示例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;
}
示例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));
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}