Altova XMLSpy 2024 Enterprise Edition

An extension function can be used to call a Java constructor. All constructors are called with the pseudo-function new().

 

If the result of a Java constructor call can be implicitly converted to XPath/XQuery datatypes, then the Java extension function will return a sequence that is an XPath/XQuery datatype. If the result of a Java constructor call cannot be converted to a suitable XPath/XQuery datatype, then the constructor creates a wrapped Java object with a type that is the name of the class returning that Java object. For example, if a constructor for the class java.util.Date is called (java.util.Date.new()), then an object having a type java.util.Date is returned. The lexical format of the returned object may not match the lexical format of an XPath datatype and the value would therefore need to be converted to the lexical format of the required XPath datatype and then to the required XPath datatype.

 

There are two things that can be done with a Java object created by a constructor:

 

It can be assigned to a variable:
<xsl:variable name="currentdate" select="date:new()" xmlns:date="java:java.util.Date" />

It can be passed to an extension function (see Instance Method and Instance Fields):
<xsl:value-of select="date:toString(date:new())" xmlns:date="java:java.util.Date" />

 

© 2017-2023 Altova GmbH