<?xml version="1.0" encoding="UTF-8"?>
<?transconnect persistedProperties="{ 'myMap' :
{ 'name' : 'My Map',
'description' : 'Map<String,Serializable>',
'type' : 'java.util.Map' } }" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:java="http://xml.apache.org/xslt/java">
<!-- type: java.util.Map<String,Serializable> -->
<xsl:param name="persistedProperties" />
<xsl:template match="/">
<!-- wrap output of 'value-of' to comment -->
<xsl:comment>
<!-- put a new table, if executed the first time -->
<xsl:value-of select="java:putIfAbsent( $persistedProperties, 'myMap', java:java.util.HashMap.new() )" />
<!-- get map property from persisted property map -->
<xsl:variable name="myMap" select="java:get( $persistedProperties, 'myMap' )" />
<!-- get saved value (or default) from map -->
<xsl:variable name="value1" select="java:getOrDefault( $myMap, 'Value 1', java:java.lang.Integer.new( 1 ) )" />
<!-- write back new value into map and map back to persisted property map -->
<xsl:value-of select="java:put( $myMap, 'Value 1', java:java.lang.Integer.new( $value1 * 2 ) )" />
<xsl:value-of select="java:put( $persistedProperties, 'myMap', $myMap )" />
</xsl:comment>
<ROOT>
<Value><xsl:value-of select="value1" /></Value>
</ROOT>
</xsl:template>
</xsl:stylesheet>
|