Altova StyleVision 2023 Enterprise Edition

An instance method has a Java object passed to it as the first argument of the method call. Such a Java object typically would be created by using an extension function (for example a constructor call) or a stylesheet parameter/variable. An XSLT example of this kind would be:

 

<xsl:stylesheet version="1.0" exclude-result-prefixes="date"

  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  xmlns:date="java:java.util.Date"

  xmlns:jlang="java:java.lang"> 

  <xsl:param name="CurrentDateselect="date:new()"/>

  <xsl:template match="/">

      <enrollment institution-id="Altova School" 
                date="{date:toString(\$CurrentDate)}" 

                type="{jlang:Object.toString(jlang:Object.getClass( date:new() ))}">

      </enrollment>

  </xsl:template>

</xsl:stylesheet>

 

In the example above, the value of the node enrollment/@type is created as follows:

 

1.An object is created with a constructor for the class java.util.Date (with the date:new() constructor).

2.This Java object is passed as the argument of the jlang.Object.getClass method.

3.The object obtained by the getClass method is passed as the argument to the jlang.Object.toString method.

 

The result (the value of @type) will be a string having the value: java.util.Date.

 

An instance field is theoretically different from an instance method in that it is not a Java object per se that is passed as an argument to the instance field. Instead, a parameter or variable is passed as the argument. However, the parameter/variable may itself contain the value returned by a Java object. For example, the parameter CurrentDate takes the value returned by a constructor for the class java.util.Date. This value is then passed as an argument to the instance method date:toString in order to supply the value of /enrollment/@date.

 

© 2017-2023 Altova GmbH