本文整理汇总了C#中System.Xml.XPath.XPathNavigator.LookupNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.LookupNamespace方法的具体用法?C# XPathNavigator.LookupNamespace怎么用?C# XPathNavigator.LookupNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.LookupNamespace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FnResolveQName
// FIXME: add a bunch of annoying datetime functions
public static object FnResolveQName (string qname, XPathNavigator element)
{
if (qname == null)
return null;
int index = qname.IndexOf (':');
string prefix = (index < 0) ? "" : qname.Substring (index);
return new XmlQualifiedName (
element.LookupNamespace (prefix),
index < 0 ? qname : qname.Substring (index + 1));
}
示例2: MSNamespaceUri
public static string MSNamespaceUri(string name, XPathNavigator currentNode) {
int colonOffset;
int len = ValidateNames.ParseQName(name, 0, out colonOffset);
if (len != name.Length) {
return string.Empty;
}
string prefix = name.Substring(0, colonOffset);
if (prefix == "xmlns") {
return string.Empty;
}
string ns = currentNode.LookupNamespace(prefix);
if (ns != null) {
return ns;
}
if (prefix == "xml") {
return XmlReservedNs.NsXml;
}
return string.Empty;
}
示例3: ReadXml
public void ReadXml(XPathNavigator node, XmlResolver resolver)
{
if (node.NodeType == XPathNodeType.Element) {
XPathNavigator el = node.Clone();
if (node.MoveToFirstAttribute()) {
do {
switch (node.LocalName) {
case "byte-order-mark":
this.ByteOrderMark = node.ValueAsBoolean;
break;
case "doctype-public":
this.DocTypePublic = node.Value;
break;
case "doctype-system":
this.DocTypeSystem = node.Value;
break;
case "encoding":
this.Encoding = Encoding.GetEncoding(node.Value);
break;
case "indent":
this.Indent = node.ValueAsBoolean;
break;
case "media-type":
this.MediaType = node.Value;
break;
case "method":
if (node.Value.Contains(":")) {
string name = XmlConvert.VerifyName(node.Value);
string[] parts = name.Split(':');
string local = parts[1];
string ns = node.LookupNamespace(parts[0]) ?? "";
XmlQualifiedName qname = new XmlQualifiedName(local, ns);
if (ns != null
&& (qname == ExtensionMethods.Base64Binary
|| qname == ExtensionMethods.HexBinary)) {
this.Method = qname;
} else {
throw new ArgumentException("The value of the method attribute must be one of: xml, html, xhtml, text, http:base64Binary or http:hexBinary.", "node");
}
} else {
switch (node.Value) {
case "xml":
this.Method = XPathSerializationMethods.Xml;
break;
case "html":
this.Method = XPathSerializationMethods.Html;
break;
case "xhtml":
this.Method = XPathSerializationMethods.XHtml;
break;
case "text":
this.Method = XPathSerializationMethods.Text;
break;
default:
throw new ArgumentException("The value of the method attribute must be one of: xml, html, xhtml, text, http:base64Binary or http:hexBinary.", "node");
}
}
break;
case "omit-xml-declaration":
this.OmitXmlDeclaration = node.ValueAsBoolean;
break;
case "src":
Uri elBaseUri = !String.IsNullOrEmpty(el.BaseURI) ?
new Uri(el.BaseURI) :
null;
if (resolver != null) {
this.Src = resolver.ResolveUri(elBaseUri, node.Value);
} else {
this.Src = (elBaseUri != null) ?
new Uri(elBaseUri, node.Value) :
new Uri(node.Value);
}
break;
default:
//.........这里部分代码省略.........
示例4: resolveNsPrefix
/// <summary>
/// This method resolves the prefix of an argument.
/// If a prefix is found, the corresponding namespace URI (if existing) is looked up
/// and substituted. Otherwise the target namespace is placed first.
/// </summary>
/// <param name="args">An argument of the function to be resolved</param>
/// <param name="xsltContext">The Xslt context for namespace resolving</param>
private string resolveNsPrefix(string args, string targetNs, XPathNavigator docContext)
{
string prefix;
string ns;
if (args.Contains(":"))
{
prefix = args.Substring(0, args.IndexOf(":"));
if (!string.IsNullOrEmpty((ns = docContext.LookupNamespace(prefix))))
return args = args.Replace(prefix + ":", ns);
return targetNs + args;
}
return targetNs + args;
}
示例5: ResolveNsPrefix
/// <summary>
/// This method resolves the prefix of an argument.
/// If a prefix is found, the corresponding namespace URI (if existing) is looked up
/// and substituted. Otherwise the target namespace is placed first.
/// </summary>
/// <param name="args">An argument of the function to be resolved</param>
/// <param name="targetNs">The target namespace</param>
/// <param name="docContext">The document context</param>
private static string ResolveNsPrefix(string args, string targetNs, XPathNavigator docContext)
{
if (args.Contains(":"))
{
var prefix = args.Substring(0, args.IndexOf(":", StringComparison.Ordinal));
string ns;
if (!string.IsNullOrEmpty((ns = docContext.LookupNamespace(prefix))))
return args.Replace(prefix + ":", ns);
return targetNs + args;
}
return targetNs + args;
}