Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem passing param to a java function from xslt

843834Apr 14 2008 — edited Apr 15 2008
HI all,

A thousand thankyou's to any who can help me.

Documentation is scarce, and I got to bed late last night. It has been a hard day of fruitless searching for a solution to this.

Problem:

Calling a named template in xsl using the with-param tag to pass in a parameter.
attempting to call a java function, specifying that parameter as an argument.
getting parse error:
ERROR: 'Cannot convert argument/return type in call to method 'java.lang.String.new(java.util.Date)''

sample code:

calling the named template
		<xsl:call-template name="calc-age">
			<xsl:with-param name="dob">
				<xsl:value-of select="/FullRecord/Patient/dob"/>
			</xsl:with-param>
		</xsl:call-template>
the template itself
	<xsl:template name="calc-age">
		<xsl:param name="dob"/>		
	    <xsl:variable name="date" select="java:util.Date.new()"/>
	    <xsl:value-of select="java:toString($date)"/>
		<xsl:variable name="sdob" select="java:lang.String.new($date)"/> 
	</xsl:template>		
the error
ERROR:  'Cannot convert argument/return type in call to method 'java.lang.String.new(java.util.Date)''
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:824)
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:613)
does anyone know what is wrong here?
And if they do, where I can find examples or a reference on how this is supposed to work?
It's driving me mad!

Thanks all!

svaens

Edited by: svaens on Apr 14, 2008 9:16 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2008
Added on Apr 14 2008
4 comments
1,698 views