How to pass java.util.Map instance as a parameter to a XSLTStylesheet

"Javalkar, Vishal" <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <DC7218B52792D340B42F0874857165162EC58EB5A7@DEWDFECCR06.wdf.sap.corp>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.