1using System.Threading.Tasks;
16 private readonly
string xpath;
17 private bool extractValue;
30 this.extractValue =
false;
63 get => this.extractValue;
64 internal set => this.extractValue = value;
74 if (
string.IsNullOrEmpty(this.xpath))
87 return Task.FromResult(this.
Evaluate(Variables));
101 object Obj = v.ValueObject;
106 else if (Obj is XmlNode N)
108 XmlNamespaceManager NamespaceManager;
111 if (Obj is XmlDocument Doc)
113 NamespaceManager =
new XmlNamespaceManager(Doc.NameTable);
114 Root = Doc.DocumentElement;
116 else if (N is XmlElement E && !(N.OwnerDocument is
null))
118 NamespaceManager =
new XmlNamespaceManager(N.OwnerDocument.NameTable);
123 NamespaceManager =
null;
127 if (NamespaceManager is
null)
135 if (
string.IsNullOrEmpty(Root.Prefix) && !
string.IsNullOrEmpty(Root.NamespaceURI))
141 foreach (XmlNode N2
in Root.ChildNodes)
143 if (N2 is XmlElement E)
147 while (ToProcess.HasFirstItem)
149 Root = ToProcess.RemoveFirst();
151 if (
string.IsNullOrEmpty(Root.Prefix) && !
string.IsNullOrEmpty(Root.NamespaceURI))
157 foreach (XmlNode N2
in Root.ChildNodes)
159 if (N2 is XmlElement E)
165 if (!
string.IsNullOrEmpty(
Namespace) && !NamespaceManager.HasNamespace(
"defualt"))
166 NamespaceManager.AddNamespace(
"default",
Namespace);
169 Result = N.SelectNodes(
Argument, NamespaceManager);
175 int i, c = Result.Count;
183 return ToElement(Result[0], this.extractValue);
188 for (i = 0; i < c; i++)
189 Items[i] =
ToElement(Result[i], this.extractValue);
191 return Operators.Vectors.VectorDefinition.
Encapsulate(Items,
false,
this);
203 if (Node is XmlText Text)
205 else if (Node is XmlCDataSection CData)
207 else if (Node is XmlAttribute Attr)
211 if (
ExtractValue && Node.HasChildNodes && Node.FirstChild == Node.LastChild && Node.FirstChild is XmlText Text2)
A chunked list is a linked list of chunks of objects of type T .
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(ChunkedList< IElement > Elements, ScriptNode Node)
Encapsulates a set of elements into a similar structure as that provided by the current element.