You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Miroslav Nachev <mi...@space-comm.com> on 2002/01/28 17:22:32 UTC
Passing parameters in XSLT
Hi!
Can anybody tell me an easy way of passing an external parameter
(an object or a value) from a Java object to a XSL stylesheet, that
will be visible during transformation.
The only way I find is by using an external function, but for some
reasons it is not convenient for me.
Thanks.
Miro
Re: Passing parameters in XSLT
Posted by John Keyes <jo...@yahoo.com>.
Hi Miroslav,
Here's an example:
...
StreamSource styleSheet = ...;
StreamSource input = ...;
StreamResult result = ...;
Transformer serializer = null;
serializer = tfactory.newTransformer(styleSheet);
serializer.setParameter("PARAM_NAME","value");
serializer.transform(input, result);
...
You can refer to the parameter "PARAM_NAME" in your XSLT
as follows:
<xsl:stylesheet ...>
<xsl:param name="PARAM_NAME"/>
<xsl:template ...>
<xsl:value-of select="$PARAM_NAME"/>
</xsl:template>
</xsl:stylesheet>
Regards,
-John K
Miroslav Nachev wrote:
> Hi!
>
> Can anybody tell me an easy way of passing an external parameter
> (an object or a value) from a Java object to a XSL stylesheet, that
> will be visible during transformation.
> The only way I find is by using an external function, but for some
> reasons it is not convenient for me.
>
> Thanks.
> Miro
>
>
>
Re: Passing parameters in XSLT
Posted by John Keyes <jo...@yahoo.com>.
Hi Miroslav,
Here's an example:
...
StreamSource styleSheet = ...;
StreamSource input = ...;
StreamResult result = ...;
Transformer serializer = null;
serializer = tfactory.newTransformer(styleSheet);
serializer.setParameter("PARAM_NAME","value");
serializer.transform(input, result);
...
You can refer to the parameter "PARAM_NAME" in your XSLT
as follows:
<xsl:stylesheet ...>
<xsl:param name="PARAM_NAME"/>
<xsl:template ...>
<xsl:value-of select="$PARAM_NAME"/>
</xsl:template>
</xsl:stylesheet>
Regards,
-John K
Miroslav Nachev wrote:
> Hi!
>
> Can anybody tell me an easy way of passing an external parameter
> (an object or a value) from a Java object to a XSL stylesheet, that
> will be visible during transformation.
> The only way I find is by using an external function, but for some
> reasons it is not convenient for me.
>
> Thanks.
> Miro
>
>
>