Altova RaptorXML+XBRL Server 2025

A static method is called directly by its Java name and by supplying the arguments for the method. Static fields (methods that take no arguments), such as the constant-value fields E and PI, are accessed without specifying any argument.

 

 

XSLT examples

Here are some examples of how static methods and fields can be called:

 

 <xsl:value-of xmlns:jMath="java:java.lang.Math
                 select="jMath:cos(3.14)" />

 

 <xsl:value-of xmlns:jMath="java:java.lang.Math
                 select="jMath:cos( jMath:PI() )" />
 
 <xsl:value-of xmlns:jMath="java:java.lang.Math
                 select="jMath:E() * jMath:cos(3.14)" />

 

Notice that the extension functions above have the form prefix:fname(). The prefix in all three cases is jMath:, which is associated with the namespace URI java:java.lang.Math. (The namespace URI must begin with java:. In the examples above it is extended to contain the class name (java.lang.Math).) The fname() part of the extension functions must match the name of a public class (e.g. java.lang.Math) followed by the name of a public static method with its argument/s (such as cos(3.14)) or a public static field (such as PI()).

 

In the examples above, the class name has been included in the namespace URI. If it were not contained in the namespace URI, then  it would have to be included in the fname() part of the extension function. For example:

 

 <xsl:value-of xmlns:java="java:
                 select="java:java.lang.Math.cos(3.14)" />

 

XQuery example

A similar example in XQuery would be:

 

 <cosine xmlns:jMath="java:java.lang.Math">

    {jMath:cos(3.14)}

 </cosine>

 

© 2018-2024 Altova GmbH