Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Transform.cs
1
using
System;
2
using
System.IO;
3
using
System.Threading.Tasks;
4
using
System.Xml;
5
using
System.Xml.Xsl;
6
using
Waher.Script
;
7
using
Waher.Script.Abstraction.Elements
;
8
using
Waher.Script.Exceptions
;
9
using
Waher.Script.Model
;
10
using
Waher.Script.Objects
;
11
12
namespace
Waher.Content.Xsl.Functions
13
{
17
public
class
Transform
:
FunctionTwoScalarVariables
18
{
27
public
Transform
(
ScriptNode
Xml,
ScriptNode
Xslt,
int
Start
,
int
Length
,
Expression
Expression
)
28
: base(Xml, Xslt,
Start
,
Length
,
Expression
)
29
{
30
}
31
35
public
override
string
FunctionName
=> nameof(
Transform
);
36
44
public
override
IElement
EvaluateScalar
(
IElement
Argument1
,
IElement
Argument2
,
Variables
Variables
)
45
{
46
if
(!(
Argument1
.AssociatedObjectValue is
string
s))
47
{
48
if
(
Argument1
.AssociatedObjectValue is XmlDocument Xml)
49
s = Xml.OuterXml;
50
else
51
s =
Expression
.
ToString
(
Argument1
.AssociatedObjectValue);
52
}
53
54
if
(!(
Argument2
.AssociatedObjectValue is XslCompiledTransform Xslt))
55
throw
new
ScriptRuntimeException
(
"Second parameter must be an XSL Transform (XSLT) object."
,
this
);
56
57
return
this.DoTransform(s, Xslt);
58
}
59
67
public
override
Task<IElement>
EvaluateScalarAsync
(
IElement
Argument1
,
IElement
Argument2
,
Variables
Variables
)
68
{
69
return
Task.FromResult<
IElement
>(this.
EvaluateScalar
(Argument1,
Argument2
,
Variables
));
70
}
71
72
private
IElement
DoTransform(
string
Xml, XslCompiledTransform Xslt)
73
{
74
return
new
StringValue
(
XSL
.
Transform
(Xml, Xslt));
75
}
76
84
public
override
IElement
EvaluateScalar
(
string
Argument1
,
string
Argument2
,
Variables
Variables
)
85
{
86
using
(StringReader s =
new
StringReader(
Argument2
))
87
{
88
using
(XmlReader r = XmlReader.Create(s))
89
{
90
XslCompiledTransform Xslt =
new
XslCompiledTransform();
91
Xslt.Load(r);
92
93
return
this.DoTransform(
Argument1
, Xslt);
94
}
95
}
96
}
97
98
}
99
}
Waher.Content.Xsl.Functions.Transform
Transform(XML,XSLT)
Definition:
Transform.cs:18
Waher.Content.Xsl.Functions.Transform.FunctionName
override string FunctionName
Name of the function
Definition:
Transform.cs:35
Waher.Content.Xsl.Functions.Transform.EvaluateScalarAsync
override Task< IElement > EvaluateScalarAsync(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition:
Transform.cs:67
Waher.Content.Xsl.Functions.Transform.EvaluateScalar
override IElement EvaluateScalar(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition:
Transform.cs:44
Waher.Content.Xsl.Functions.Transform.Transform
Transform(ScriptNode Xml, ScriptNode Xslt, int Start, int Length, Expression Expression)
Transform(XML,XSLT)
Definition:
Transform.cs:27
Waher.Content.Xsl.Functions.Transform.EvaluateScalar
override IElement EvaluateScalar(string Argument1, string Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition:
Transform.cs:84
Waher.Content.Xsl.XSL
Static class managing loading of XSL resources stored as embedded resources or in content files.
Definition:
XSL.cs:15
Waher.Content.Xsl.XSL.Transform
static string Transform(string XML, XslCompiledTransform Transform)
Transforms an XML document using an XSL transform.
Definition:
XSL.cs:162
Waher.Script.Exceptions.ScriptRuntimeException
Script runtime exception.
Definition:
ScriptRuntimeException.cs:10
Waher.Script.Expression
Class managing a script expression.
Definition:
Expression.cs:39
Waher.Script.Expression.ToString
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition:
Expression.cs:4496
Waher.Script.Model.FunctionTwoScalarVariables
Base class for funcions of two scalar variables.
Definition:
FunctionTwoScalarVariables.cs:15
Waher.Script.Model.FunctionTwoVariables.Argument2
ScriptNode Argument2
Function argument 2.
Definition:
FunctionTwoVariables.cs:51
Waher.Script.Model.FunctionTwoVariables.Argument1
ScriptNode Argument1
Function argument 1.
Definition:
FunctionTwoVariables.cs:46
Waher.Script.Model.ScriptNode
Base class for all nodes in a parsed script tree.
Definition:
ScriptNode.cs:69
Waher.Script.Model.ScriptNode.Length
int Length
Length of expression covered by node.
Definition:
ScriptNode.cs:101
Waher.Script.Model.ScriptNode.Start
int Start
Start position in script expression.
Definition:
ScriptNode.cs:92
Waher.Script.Objects.StringValue
String value.
Definition:
StringValue.cs:13
Waher.Script.Variables
Collection of variables.
Definition:
Variables.cs:25
Waher.Script.Abstraction.Elements.IElement
Basic interface for all types of elements.
Definition:
IElement.cs:20
Waher.Content.Xsl.Functions
Definition:
Transform.cs:13
Waher.Script.Abstraction.Elements
Definition:
AbelianGroupElement.cs:5
Waher.Script.Exceptions
Definition:
ScriptAbortedException.cs:4
Waher.Script.Model
Definition:
BinaryBooleanOperator.cs:8
Waher.Script.Objects
Definition:
BooleanValue.cs:7
Waher.Script
Definition:
Duration.cs:8
IoTGateway
Content
Waher.Content.Xsl
Functions
Transform.cs
Generated by
1.9.5