Hi,

Apparently, Xalan (the one bundled with JDK 6 at-least) complains when a 
java.util.Map is passed as a parameter to an XSLT stylesheet. 

Assuming, I have a snippet of code as:

Map inputparam = new HashMap(); 
inputparam.put("greeting", "hi there");
transformer.setParameter("inputparam", inputparam);
...
transformer.transform(...);

and I have a simple XSLT that attempts to get the key 'greeting' from this

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:map="xalan://java.util.HashMap"
        extension-element-prefixes="map">
        
        <xsl:param name="inputparam" />
        
        <xsl:template match="/">
                <xsl:variable name="greeting"
                        select="map:get($inputparam, 'greeting')" />
                <greeting><xsl:value-of select="greeting"/></greeting>          
        </xsl:template>
</xsl:stylesheet>

I obtain the following error:

ERROR:  'Cannot find external method 'java.util.HashMap.get' (must be public).'
FATAL ERROR:  'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile 
stylesheet
        at 
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:825)
        at 
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:614)
        at xalanxslttest.ExecuteXslt.main(ExecuteXslt.java:36)


Is there a way to solve this? Is this supported?

All help/advice appreciated!
Thanks & Regards,
Vishal

Reply via email to