I managed to find a nice workaround actually. Somewhere in the pipeline I need to determine image width and height based on scanning someimage.eps boxdimension properties
So when I get to the point where I want to generate <image href="someimage.eps" width="75" height="83"/> I actually generate a jx-template ------------------------------------------------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <!-- Author: Robby Pelssers --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:nxp="http://www.nxp.com" xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" xmlns:cinclude="http://apache.org/cocoon/include/1.0" exclude-result-prefixes="fn nxp"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <jx:template> <xsl:apply-templates/> </jx:template> </xsl:template> <xsl:function name="nxp:getBoxDimensionWidthJexlExpression" as="xs:string"> <xsl:param name="graphicId"/> <xsl:value-of select="concat('${datasheetBuilder.getBoxDimensionWidth("', $graphicId, '")}')"/> </xsl:function> <xsl:function name="nxp:getBoxDimensionHeightJexlExpression" as="xs:string"> <xsl:param name="graphicId"/> <xsl:value-of select="concat('${datasheetBuilder.getBoxDimensionHeight("', $graphicId, '")}')"/> </xsl:function> <!-- this function generates the corresponding DITA image tag --> <xsl:function name="nxp:getImageTag"> <xsl:param name="graphicId"/> <xsl:variable name="src" select="concat('servlet:shared:/tdm/graphic/', $graphicId, '/', $figure_extension)"/> <image href="{concat($graphicId, '.', $figure_extension)}" width="{nxp:getBoxDimensionWidthJexlExpression($graphicId)}" height="{nxp:getBoxDimensionHeightJexlExpression($graphicId)}"> </xsl:function> <!-- copy all nodes and attributes which are not processed by one of available templates --> <xsl:template match="@*|node()"> <xsl:copy copy-namespaces="no"> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> ------------------------------------------------------------------------------------------------------------------- Which I use as my generator from the main pipeline: <map:match pattern="generateProductTopics"> <map:generate src="cocoon:/generateProductTopics-step-6" type="jx"/> <map:serialize type="xml"/> </map:match> So now I have the advantage of being able to call Beans from my Spring ApplicationContext and do caching like below: public class DatasheetBuilderImpl implements DatasheetBuilder { private ImageCache imageCache; public void setImageCache(ImageCache imageCache) { this.imageCache = imageCache; } public ImageCache getImageCache() { return this.imageCache; } /** Start of convenience methods **/ public int getBoxDimensionWidth(String graphicId) { return getImageCache().getBoxDimension(graphicId).getWidth(); } public int getBoxDimensionHeight(String graphicId) { return getImageCache().getBoxDimension(graphicId).getHeight(); } } I think it's a pretty cool solution (workaround) to get performance boosts in batch processing. Kind regards, Robby Pelssers -----Original Message----- From: Robby Pelssers [mailto:robby.pelss...@ciber.com] Sent: Tuesday, March 09, 2010 4:41 PM To: users@cocoon.apache.org Subject: Saxon extensions / using Spring application Context Hi all, I know you can call static java methods from xslt and even construct new java objects. But that happens NOT to match my use case. Short description of my use case: I have a datasheetbuilder bean defined in my applicationContext: <bean id="datasheetBuilder" class="com.nxp.spider2.application.DatasheetBuilderImpl" scope="request"> <property name="spider" ref="spiderBean"/> <property name="imageCache" ref="imageCache"/> </bean> What I would like to do is call methods on this bean from within transformers (xslt) in the pipelines processing the original request. Has anyone an idea if this would be possible somehow and if so can you point me to some documentation or explain how to accomplish this. I can easily imagine this would be possible by writing a custom java transformer (not using xslt) which has access to the applicationContext but this involves quite a bit of work so... Kind regards, Robby Pelssers