Hello!
What I would like to do is use Generics and template my Buffer class; class Buffer <T>. This I can easily do but I then need to create instances of these buffers in my XSLTs can I do this? If so then how?
I have had a play with things but I think its 'working' by accident.
Code:
import java.util.ArrayList;
public class Template <T>
{
ArrayList < T >values = null ;
public Template(T value)
{
this.values = new ArrayList<T>() ;
}
public T getValue(int index) { return values.get(index) ; }
public void addValue(T value) { this.values.add(value) ; }
public int getSize() { return this.values.size() ; }
}
Code:
<xsl:if test="./xs:boolean(@test)">
<xsl:variable name="tests" select="Template:new(0)"/>
<xsl:value-of select="Template:addValue($tests, 44.3)"/>
<xsl:value-of select="Template:addValue($tests, 'string')"/>
<xsl:for-each select="0 to Template:getSize($tests)-1">
<xsl:message select="'Value : ', Template:getValue($tests, .)"/>
</xsl:for-each>
</xsl:if>
This is the output I get when executed in Oxygen.
Code:
Description: [Saxon-PE] Value : 44.3
Description: [Saxon-PE] Value : string
I would have expected an exception when assigning a string to what is (or should be) a double so am I wasting my time?
--
William