[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Java Extension Optimization


Subject: Re: [xsl] Java Extension Optimization
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 18 Oct 2013 22:12:44 +0100

There's no completely clean way of adding code with side-effects to an XSLT
transformation, but my usual way to do this is to use xsl:value-of:

> <xsl:value-of
select="xisComDocRsrcs:addImage($commonDocResources,'arrow_summary_path.gif')
"/>

Saxon goes to special efforts to avoid reasoning that the return type of the
method is void and therefore calling it has no effect on the
transformation....

Michael Kay
Saxonica


On 18 Oct 2013, at 21:04, Craig Sampson wrote:

> Hello,
>  I have several java extensions that I use to pass data to other processes
from my transforms. I've been using xml:message's to write unnecessary values
to my log file to prevent Saxon from discarding my variables, since it doesn't
see them used/referenced in my transform.
>
>  Here's an example:
>
>            <xsl:variable name="keepGraphic"
select="xisComDocRsrcs:addImage($commonDocResources,'arrow_summary_path.gif')
"/>
>            <xsl:if test="$keepGraphic=true()">
>              <xsl:message>xislog~debug::keepGraphic arrow_summary_path.gif
<xsl:value-of select="$keepGraphic"/></xsl:message>
>            </xsl:if>
>
>  In this case I am letting the extension know that I want a particular
graphic included with the deliverable that I am creating. This extension
prevents unused graphics from finding their way into EPUB deliverables where
they cause problems.
>
>  Is there a better way to prevent Saxon from discarding my extension that
doesn't require me to write something to an output stream?
>
> Thanks,
>   Craig


Current Thread
Keywords