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 "Richard R. McKinley" <mc...@sosstaffing.com> on 2003/09/08 23:42:50 UTC

Xalan javaclass extension best place to 'Set'

When using the javaclass extension in Xalan I have been using <xsl:if/> 
to use Set methods.  I can't use <xsl:value-of/> because I don't want 
any results of the setters to show up in the content.  Problem is, 
<xsl:if/> only works inside of templates, etc. and not inside of 
<xsl:stylesheet> where I often need to use a Java setter.  Is there a 
better way to do this?: <xsl:if test="java:add($calendar, 
$month-field-value, $month-offset)"/>

Thanks,
RRM


Re: Xalan javaclass extension best place to 'Set'

Posted by "Richard R. McKinley" <mc...@sosstaffing.com>.
Santiago Pericas-Geertsen wrote:

> <xsl:variable name="foo" select="java:..."/>
>
> Since XSLT is pure (i.e. no side effects) there's really no elegant 
> way of doing this. 

After thinking about your response it would probably be best to not rely 
on Java set methods alone, but rather send a modified clone of the 
original object as a parameter to the sub-template.  That would make it 
functionally safer.  Thanks for the response as I will certainly need to 
use the dummy variable to prepare the parameter.

Thanks,

RRM


XSLT Question, but related to Java extensions

Posted by "Richard R. McKinley" <mc...@sosstaffing.com>.
Is it possible in XSLT to destroy a variable?  I know that its value 
cannot change after definition, but can it be removed?  Obviously, I 
could choose to not use it anymore and call it gone, but is there a 
formal way?

Thanks,

RRM


Re: Xalan javaclass extension best place to 'Set'

Posted by "Richard R. McKinley" <mc...@sosstaffing.com>.
Woah, hold on a minute everyone.  I tried the dummy variable technique 
and it looks like Xalan-J is using some lazy evaluation.  The select 
will not be called until you run a <xsl:value-of/> for the dummy 
variable.  So, it looks like it is best to only use Java set methods 
while creating parameters to pass to sub-templates.  Then lazy 
evaluation is exactly what you would want and expect.

Cheers,

RRM