2using System.Collections.Generic;
3using System.Threading.Tasks;
17 private readonly
string xpath;
18 private bool extractValue;
31 this.extractValue =
false;
64 get => this.extractValue;
65 internal set => this.extractValue = value;
75 if (
string.IsNullOrEmpty(this.xpath))
102 object Obj = v.ValueObject;
107 else if (Obj is XmlNode N)
109 XmlNamespaceManager NamespaceManager;
112 if (Obj is XmlDocument Doc)
114 NamespaceManager =
new XmlNamespaceManager(Doc.NameTable);
115 Root = Doc.DocumentElement;
117 else if (N is XmlElement E && !(N.OwnerDocument is
null))
119 NamespaceManager =
new XmlNamespaceManager(N.OwnerDocument.NameTable);
124 NamespaceManager =
null;
128 if (NamespaceManager is
null)
136 if (
string.IsNullOrEmpty(Root.Prefix) && !
string.IsNullOrEmpty(Root.NamespaceURI))
140 LinkedList<XmlElement> ToProcess =
new LinkedList<XmlElement>();
142 foreach (XmlNode N2
in Root.ChildNodes)
144 if (N2 is XmlElement E)
145 ToProcess.AddLast(E);
148 while (!(ToProcess.First is
null))
150 Root = ToProcess.First.Value;
151 ToProcess.RemoveFirst();
153 if (
string.IsNullOrEmpty(Root.Prefix) && !
string.IsNullOrEmpty(Root.NamespaceURI))
159 foreach (XmlNode N2
in Root.ChildNodes)
161 if (N2 is XmlElement E)
162 ToProcess.AddLast(E);
168 NamespaceManager.AddNamespace(
"default",
Namespace);
171 Result = N.SelectNodes(
Argument, NamespaceManager);
177 int i, c = Result.Count;
185 return ToElement(Result[0], this.extractValue);
190 for (i = 0; i < c; i++)
191 Items[i] =
ToElement(Result[i], this.extractValue);
193 return Operators.Vectors.VectorDefinition.
Encapsulate(Items,
false,
this);
205 if (Node is XmlText Text)
207 else if (Node is XmlCDataSection CData)
209 else if (Node is XmlAttribute Attr)
213 if (
ExtractValue && 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.
Represents a constant element value.
Base class for funcions of one scalar variable.
ScriptNode Argument
Function argument.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
int Start
Start position in script expression.
static readonly ObjectValue Null
Null value.
Node repesenting an XPath expression
bool ExtractValue
If the value should be extracted.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
XPath(ScriptNode XPath, int Start, int Length, Expression Expression)
Node repesenting an XPath expression
XPath(string XPath, bool ExtractValue, int Start, int Length, Expression Expression)
Node repesenting an XPath expression
string XPathExpression
XPATH expression
static IElement ToElement(XmlNode Node, bool ExtractValue)
Encapsulates an XML Node for use in script.
override string FunctionName
Name of the function
override IElement EvaluateScalar(string Argument, Variables Variables)
Evaluates the function on a scalar argument.
override Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
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.