Running custom Java functions within XSLT and SAXON (9.1.8)

一曲冷凌霜 提交于 2019-12-04 19:19:59

You need the -cp option of your java command e.g. java -cp ".;%~dp0\saxonb9-1-0-8j\saxon9.jar" net.sf.saxon.Transform -s:"data.xml" -xsl:"transformation.xsl" -o:"result.xml" where you need to make sure that the directory with your ImageInfo is on the class path, I have added ., assuming the class is in your current working directory.

However, note that ImageInfo:getImageWidth(@src) would try to call a static method getImageWidth, you have instance methods, the method you have is called getWidth and it does not take an argument.

See the documentation for that old version of Saxon 9, it should be available on http://saxon.sourceforge.net/.

Once you've sorted out your classpath problems as Martin suggests, the code you want will be something like this:

<xsl:variable name="image" select="ImageInfo:new(@src)"/>
[image] file found: 
   <xsl:value-of select="ImageInfo:getWidth($image)"/> x 
   <xsl:value-of select="ImageInfo:getHeight($image)"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!