Altova StyleVision 2023 Enterprise Edition

An extension function can be used to call a .NET constructor. All constructors are called with the pseudo-function new(). If there is more than one constructor for a class, then the constructor that most closely matches the number of arguments supplied is selected. If no constructor is deemed to match the supplied argument/s, then a 'No constructor found' error is returned.

 

Constructors that return XPath/XQuery datatypes

If the result of a .NET constructor call can be implicitly converted to XPath/XQuery datatypes, then the .NET extension function will return a sequence that is an XPath/XQuery datatype.

 

Constructors that return .NET objects

If the result of a .NET constructor call cannot be converted to a suitable XPath/XQuery datatype, then the constructor creates a wrapped .NET object with a type that is the name of the class returning that object. For example, if a constructor for the class System.DateTime is called (with System.DateTime.new()), then an object having a type System.DateTime is returned.

 

The lexical format of the returned object may not match the lexical format of a required XPath datatype. In such cases, the returned value would need to be: (i) converted to the lexical format of the required XPath datatype; and (ii) cast to the required XPath datatype.

 

There are three things that can be done with a .NET object created by a constructor:

 

It can be used within a variable:
<xsl:variable name="currentdate" select="date:new(2008, 4, 29)" xmlns:date="clitype:System.DateTime" />

It can be passed to an extension function (see Instance Method and Instance Fields):
<xsl:value-of select="date:ToString(date:new(2008, 4, 29))" xmlns:date="clitype:System.DateTime" />

It can be converted to a string, number, or boolean:

<xsl:value-of select="xs:integer(date:get_Month(date:new(2008, 4, 29)))" xmlns:date="clitype:System.DateTime" />

 

© 2017-2023 Altova GmbH