本文整理汇总了C#中System.Xml.XPath.XPathNodeIterator类的典型用法代码示例。如果您正苦于以下问题:C# XPathNodeIterator类的具体用法?C# XPathNodeIterator怎么用?C# XPathNodeIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XPathNodeIterator类属于System.Xml.XPath命名空间,在下文中一共展示了XPathNodeIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DebuggerOptions
internal DebuggerOptions(XPathNodeIterator iter)
{
while (iter.MoveNext ()) {
switch (iter.Current.Name) {
case "File":
file = iter.Current.Value;
break;
case "InferiorArgs":
append_array (ref inferior_args, iter.Current.Value);
break;
case "JitArguments":
append_array (ref jit_arguments, iter.Current.Value);
break;
case "WorkingDirectory":
WorkingDirectory = iter.Current.Value;
break;
case "MonoPrefix":
MonoPrefix = iter.Current.Value;
break;
case "MonoPath":
MonoPath = iter.Current.Value;
break;
default:
throw new InternalError ();
}
}
if (inferior_args == null)
inferior_args = new string [0];
}
示例2: difference2
/// <summary>
/// Implements an optimized algorithm for the following function
/// node-set difference(node-set, node-set)
/// Uses document identification and binary search,
/// based on the fact that a node-set is always in document order.
/// </summary>
/// <param name="nodeset1">An input nodeset</param>
/// <param name="nodeset2">Another input nodeset</param>
/// <returns>The those nodes that are in the node set
/// passed as the first argument that are not in the node set
/// passed as the second argument.</returns>
/// <author>Dimitre Novatchev</author>
private XPathNodeIterator difference2(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
{
ArrayList arDocs = new ArrayList();
ArrayList arNodes2 = new ArrayList(nodeset2.Count);
while(nodeset2.MoveNext())
{
arNodes2.Add(nodeset2.Current.Clone());
}
auxEXSLT.findDocs(arNodes2, arDocs);
ExsltNodeList enlResult = new ExsltNodeList();
while(nodeset1.MoveNext())
{
XPathNavigator currNode = nodeset1.Current;
if(!auxEXSLT.findNode(arNodes2, arDocs, currNode) )
enlResult.Add(currNode.Clone());
}
return ExsltCommon.ExsltNodeListToXPathNodeIterator(enlResult);
}
示例3: Evaluate
public override object Evaluate(XPathNodeIterator nodeIterator)
{
return GetValue(_op,
XmlConvertEx.ToXPathDouble(_opnd1.Evaluate(nodeIterator)),
XmlConvertEx.ToXPathDouble(_opnd2.Evaluate(nodeIterator))
);
}
示例4: Evaluate
public override object Evaluate(XPathNodeIterator context)
{
outputBuffer.Clear();
count = 0;
return input.Evaluate(context);// This is trick. IDQuery needs this value. Otherwise we would return this.
// All subclasses should and would anyway override thismethod and return this.
}
示例5: Evaluate
public override object Evaluate(XPathNodeIterator context)
{
base.contextNode = context.Current.Clone();
base.contextNode.MoveToRoot();
base.count = 0;
return this;
}
示例6: Evaluate
public override object Evaluate(XPathNodeIterator nodeIterator)
{
if (xsltContext == null)
{
throw XPathException.Create(SR.Xp_NoContext);
}
// calculate arguments:
object[] argVals = new object[_args.Count];
for (int i = 0; i < _args.Count; i++)
{
argVals[i] = _args[i].Evaluate(nodeIterator);
if (argVals[i] is XPathNodeIterator)
{// ForBack Compat. To protect our queries from users.
argVals[i] = new XPathSelectionIterator(nodeIterator.Current, _args[i]);
}
}
try
{
return ProcessResult(_function.Invoke(xsltContext, argVals, nodeIterator.Current));
}
catch (Exception ex)
{
throw XPathException.Create(SR.Xp_FunctionFailed, QName, ex);
}
}
示例7: FilterNodes
public static XPathNodeIterator FilterNodes(XPathNodeIterator nodeset, string xpath)
{
try
{
while (nodeset.MoveNext())
{
var nav = nodeset.Current;
var manager = new XmlNamespaceManager(nav.NameTable);
nav.MoveToFollowing(XPathNodeType.Element);
foreach (var ns in nav.GetNamespacesInScope(XmlNamespaceScope.All))
{
manager.AddNamespace(ns.Key, ns.Value);
}
var result = nav.Evaluate(xpath, manager);
if (result is XPathNodeIterator) {
return (XPathNodeIterator)result;
} else {
XmlDocument doc = new XmlDocument();
doc.LoadXml("<result expression=\"" + xpath + "\">" + result.ToString() + "</result>");
return (XPathNodeIterator)doc.DocumentElement.CreateNavigator().Evaluate("/result");
}
}
}
catch (Exception ex)
{
return ex.ToXPathNodeIterator();
}
return nodeset;
}
示例8: Evaluate
public override object Evaluate(XPathNodeIterator context)
{
base.Evaluate(context);
List<XPathNavigator> parentStk = new List<XPathNavigator>();
Stack<XPathNavigator> stack = new Stack<XPathNavigator>();
while ((base.currentNode = base.qyInput.Advance()) != null)
{
stack.Push(base.currentNode.Clone());
}
while (stack.Count != 0)
{
XPathNavigator nav = stack.Pop();
if (((nav.NodeType != XPathNodeType.Attribute) && (nav.NodeType != XPathNodeType.Namespace)) && this.NotVisited(nav, parentStk))
{
XPathNavigator e = nav.Clone();
if (e.MoveToParent())
{
e.MoveToFirstChild();
while (!e.IsSamePosition(nav))
{
if (this.matches(e))
{
base.Insert(base.outputBuffer, e);
}
if (e.MoveToNext())
{
}
}
}
}
}
return this;
}
示例9: avg
/// <summary>
/// Implements the following function
/// number avg(node-set)
/// </summary>
/// <param name="iterator"></param>
/// <returns>The average of all the value of all the nodes in the
/// node set</returns>
/// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks>
public double avg(XPathNodeIterator iterator)
{
double sum = 0;
int count = iterator.Count;
if (count == 0)
{
return Double.NaN;
}
try
{
while (iterator.MoveNext())
{
sum += XmlConvert.ToDouble(iterator.Current.Value);
}
}
catch (FormatException)
{
return Double.NaN;
}
return sum / count;
}
示例10: Read
public List<TSK> Read(XPathNodeIterator iterator)
{
var tsks = new List<TSK>();
if (iterator.Count == 0)
return tsks;
foreach (XPathNavigator node in iterator)
{
if (node.SelectChildren("TLG", node.NamespaceURI).Count == 0)
continue;
var tsk = new TSK
{
A = GetStringValue(node, "A"),
B = GetStringValue(node, "B"),
C = GetStringValue(node, "C"),
D = GetStringValue(node, "D"),
E = GetStringValue(node, "E"),
F = GetStringValue(node, "F"),
G = GetEnumValue(node, "G"),
H = GetByteValue(node, "H"),
I = GetByteValue(node, "I"),
J = GetByteValue(node, "J"),
Items = GetItems(node),
};
tsks.Add(tsk);
}
return tsks;
}
示例11: highest
/// <summary>
/// Implements the following function
/// node-set highest(node-set)
/// </summary>
/// <param name="iterator">The input nodeset</param>
/// <returns>All the nodes that contain the max value in the nodeset</returns>
public static XPathNodeIterator highest(XPathNodeIterator iterator){
ExsltNodeList newList = new ExsltNodeList();
double max, t;
if(iterator.Count == 0){
return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList);
}
try{
iterator.MoveNext();
max = XmlConvert.ToDouble(iterator.Current.Value);
newList.Add(iterator.Current.Clone());
while (iterator.MoveNext()){
t = XmlConvert.ToDouble(iterator.Current.Value);
if(t > max){
max = t;
newList.Clear();
newList.Add(iterator.Current.Clone());
}else if( t == max){
newList.Add(iterator.Current.Clone());
}
}
}catch(Exception){ //return empty node set
newList.Clear();
return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList);
}
return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList);
}
示例12: Evaluate
public override object Evaluate(XPathNodeIterator context)
{
object obj2 = base.Evaluate(context);
XPathNavigator contextNode = context.Current.Clone();
switch (base.GetXPathType(obj2))
{
case XPathResultType.Number:
this.ProcessIds(contextNode, StringFunctions.toString((double) obj2));
break;
case XPathResultType.String:
this.ProcessIds(contextNode, (string) obj2);
break;
case XPathResultType.Boolean:
this.ProcessIds(contextNode, StringFunctions.toString((bool) obj2));
break;
case XPathResultType.NodeSet:
XPathNavigator navigator2;
while ((navigator2 = base.input.Advance()) != null)
{
this.ProcessIds(contextNode, navigator2.Value);
}
break;
case ((XPathResultType) 4):
this.ProcessIds(contextNode, ((XPathNavigator) obj2).Value);
break;
}
return this;
}
示例13: XPathResult
internal XPathResult(XPathNodeIterator nodeSetResult)
: this()
{
this.nodeSetResult = nodeSetResult;
this.internalIterator = nodeSetResult as SafeNodeSequenceIterator;
this.resultType = XPathResultType.NodeSet;
}
示例14: min
/// <summary>
/// Implements the following function
/// string date2:min(node-set)
/// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-min.xml
/// </summary>
/// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks>
public string min(XPathNodeIterator iterator)
{
TimeSpan min, t;
if (iterator.Count == 0)
{
return "";
}
try
{
iterator.MoveNext();
min = XmlConvert.ToTimeSpan(iterator.Current.Value);
while (iterator.MoveNext())
{
t = XmlConvert.ToTimeSpan(iterator.Current.Value);
min = (t < min) ? t : min;
}
}
catch (FormatException)
{
return "";
}
return XmlConvert.ToString(min);
}
示例15: min
/// <summary>
/// Implements the following function
/// number min(node-set)
/// </summary>
/// <param name="iterator"></param>
/// <returns></returns>
public double min(XPathNodeIterator iterator)
{
double min, t;
if (iterator.Count == 0)
{
return Double.NaN;
}
try
{
iterator.MoveNext();
min = XmlConvert.ToDouble(iterator.Current.Value);
while (iterator.MoveNext())
{
t = XmlConvert.ToDouble(iterator.Current.Value);
min = (t < min) ? t : min;
}
}
catch
{
return Double.NaN;
}
return min;
}