Project

Profile

Help

non-static java methods calls fail wit params

Added by Anonymous over 16 years ago

Legacy ID: #4868598 Legacy Poster: saul simhon (saulsim)

Hi, I'm running into an issue when calling a non-static methods with parameters. I understand that in the XSLT call, the parameter list is supposed to have one extra, the instance object to call the method on. This seems to work well when the instance method does not expect any parameters, but when the method excepts parameters I get the following error: Cannot convert supplied XPath value to the required type for the extension function. Does anyone have it working with parameters? Can anyone show me an example. Your help is greatly appreciated! Here is my code: public class Taxonomy { private transient Map<String, String> itsTaxonomyMap; private transient Map<String, String> itsTaxonomyBase; public String getURL(String inTaxonomyMapKey, String inBaseKey) { return (itsTaxonomyBase.get(inBaseKey) + itsTaxonomyMap.get(inTaxonomyMapKey) + kSuffix); } ....... } public class XSLTTransform { ...... private Taxonomy itsTaxonomy; ...... public void doTransform() { ....... TransformerFactory theTransformerFactory = TransformerFactory.newInstance(); theTransformer = theTransformerFactory.newTransformer(theXsltSource); theTransformer.setParameter("inTaxonomy", (Object) itsTaxonomy ); theTransformer.transform(theXmlSource, theResult); } ..... } <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:taxonomy="java:org.my.package.Taxonomy" exclude-result-prefixes="taxonomy" version="2.0"> <xsl:output method="html" omit-xml-declaration="yes" indent="yes"/> <xsl:param name="inTaxonomy"/> <xsl:template match="/"> <xsl:variable name="url" select="taxonomy:getURL($inTaxonomy, 'base1', 'key1')"/> <xsl:variable name="id"><xsl:value-of select="//article/@id"/></xsl:variable> <xsl:variable name="key"><xsl:value-of select="//article/@id"/></xsl:variable> <xsl:variable name="url2" select="taxonomy:getURL($inTaxonomy, $id, $key)"/> </xsl:template> ....


Replies (1)

RE: non-static java methods calls fail wit pa - Added by Anonymous over 16 years ago

Legacy ID: #4869961 Legacy Poster: Michael Kay (mhkay)

Duplicate posting.

    (1-1/1)

    Please register to reply