1using System.Collections.Generic;
2using System.Threading.Tasks;
48 object Obj =
Argument1.AssociatedObjectValue;
53 else if (Obj is XmlNode N)
54 Result = Evaluate(N,
Argument2.AssociatedObjectValue?.
ToString() ??
string.Empty);
58 int i, c = Result.Count;
71 for (i = 0; i < c; i++)
74 return Operators.Vectors.VectorDefinition.
Encapsulate(Items,
false,
this);
90 internal static XmlNodeList Evaluate(XmlNode N,
string XPath)
92 XmlNamespaceManager NamespaceManager;
96 if (N is XmlDocument Doc)
98 NamespaceManager =
new XmlNamespaceManager(Doc.NameTable);
99 Root = Doc.DocumentElement;
101 else if (N is XmlElement E && !(N.OwnerDocument is
null))
103 NamespaceManager =
new XmlNamespaceManager(N.OwnerDocument.NameTable);
108 NamespaceManager =
null;
112 if (NamespaceManager is
null)
113 Result = N.SelectNodes(XPath);
116 if (XPath.Contains(
"default:"))
120 if (
string.IsNullOrEmpty(Root.Prefix) && !
string.IsNullOrEmpty(Root.NamespaceURI))
124 LinkedList<XmlElement> ToProcess =
new LinkedList<XmlElement>();
126 foreach (XmlNode N2
in Root.ChildNodes)
128 if (N2 is XmlElement E)
129 ToProcess.AddLast(E);
132 while (!(ToProcess.First is
null))
134 Root = ToProcess.First.Value;
135 ToProcess.RemoveFirst();
137 if (
string.IsNullOrEmpty(Root.Prefix) && !
string.IsNullOrEmpty(Root.NamespaceURI))
143 foreach (XmlNode N2
in Root.ChildNodes)
145 if (N2 is XmlElement E)
146 ToProcess.AddLast(E);
152 NamespaceManager.AddNamespace(
"default",
Namespace);
155 Result = N.SelectNodes(XPath, NamespaceManager);
168 if (Node is XmlText Text)
170 else if (Node is XmlCDataSection CData)
172 else if (Node is XmlAttribute Attr)
176 if (Node.HasChildNodes && Node.FirstChild == Node.LastChild && Node.FirstChild is XmlText Text2)
Script runtime exception.
Class managing a script expression.
static bool TryParse(string s, out double Value)
Tries to parse a double-precision floating-point value.
Base class for funcions of two scalar variables.
ScriptNode Argument2
Function argument 2.
ScriptNode Argument1
Function argument 1.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
override string ToString()
int Start
Start position in script expression.
static readonly ObjectValue Null
Null value.
Performs an XML slection using XPATH.
override string FunctionName
Name of the function
static IElement ToElement(XmlNode Node)
Encapsulates an XML Node for use in script.
SelectXml(ScriptNode Xml, ScriptNode Name, int Start, int Length, Expression Expression)
Performs an XML slection using XPATH.
override IElement EvaluateScalar(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
override string[] DefaultArgumentNames
Default Argument names
override Task< IElement > EvaluateScalarAsync(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Basic interface for all types of elements.
IElement Encapsulate(ICollection< IElement > Elements, ScriptNode Node)
Encapsulates a set of elements into a similar structure as that provided by the current element.