Maintenance: Planio will be observing a scheduled maintenance window this Tuesday, November 5, 2024 from 03:00 UTC until 06:30 UTC to perform urgent network maintenance in our primary data center. Your Planio account will be unavailable during this maintenance window.
Static Java Function Problem
Added by Anonymous over 17 years ago
Legacy ID: #4169534 Legacy Poster: Dave (dave_pick)
I have recently upgraded from version 8.8.02 to 8.9 and my XSLT now fails to compile with the following error: ERROR: 'The first argument to the non-static Java function 'getStyleValue' is not a valid object reference.' FATAL ERROR: 'Could not compile stylesheet' This worked with the previous version, has anything changed when implementing java extension functions using static methods? Many Thanks Dave
Replies (8)
Please register to reply
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4169559 Legacy Poster: Michael Kay (mhkay)
I'm not aware of a specific change that would have caused this, but there's a general trend towards doing more static type checking and it looks as it this has tripped you up. We'll need to see the detail of your code to see what's happening.
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4169821 Legacy Poster: Dave (dave_pick)
Here are the XSLT details: <xsl:stylesheet version="1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:sl="java:fsl.LetterHelper"> ... <xsl:variable name="style-setting"> <xsl:value-of select="sl:getStyleValue($style-attribute, $style-name)"></xsl:value-of> </xsl:variable> ... and the Java static method implementation: public static String getStyleValue(final String styleAttribute, final String styleName) { if (styleAttribute == null || styleName == null) return ""; String parts[]; final String styles[] = styleAttribute.split(";"); for (final String style : styles) { parts = style.trim().split(":"); if (parts.length == 2 && parts[0].trim().equalsIgnoreCase(styleName)) return parts[1].trim(); } return ""; } Cheers Dave
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4169911 Legacy Poster: Michael Kay (mhkay)
The error message you quote refers to a non-static Java method. Is it possible you also have a non-static method with the same name? But I strongly suspect that you are not actually loading Saxon, but Xalan, because I can't find any Saxon error messages that resemble the ones you quote. Check that you have downloaded the 8.9.0.2 patch release which fixes problems in the META-INF/services file in the JAR.
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4170131 Legacy Poster: Dave (dave_pick)
Problem solved by upgrading to 8.9.02. The saxon transform factory was not being picked up due to the naming issue with META-INF/service .vs. META-INF/services Many Thanks Dave
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4196315 Legacy Poster: Jess Holle (jessholle)
Dave's resolution doesn't immediately make sense to me, but I'll give 8.9.0.2 a try... I'm having the same issue, but overall Saxon is going ape over a host of Java extension functions. The XSLT is below. Saxon is giving errors about inability to find class java:java.io.File, etc -- unless, of course, Saxon is not actually getting used, which would explain Dave's resolution... What fixes are in 8.9.0.2, by the way? I can't really see any clear traceability on this (and I need to patch in another 8.9 fix if it is not in 8.9.0.2). <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="file uri url xsl" xmlns:file="java:java.io.File" xmlns:uri="java:java.net.URI" xmlns:url="java:java.net.URL"> <xsl:output method="xml" indent="yes" encoding="UTF-8" doctype-public="-//NetBeans//DTD Library Declaration 1.0//EN" doctype-system="http://www.netbeans.org/dtds/library-declaration-1_0.dtd"/> <xsl:param name="projectName"/> <xsl:param name="wtCodebase"/> <xsl:param name="windchillSrcDir"/> <xsl:template match="/"> <library version="1.0"> <name><xsl:value-of select='$projectName'/>-Codebase</name> <type>j2se</type> <volume> <type>classpath</type> <resource><xsl:value-of select='url:toString(uri:toURL(file:toURI(file:new(string($wtCodebase)))))'/></resource> </volume> <volume> <type>src</type> <resource><xsl:value-of select='url:toString(uri:toURL(file:toURI(file:new(string($windchillSrcDir)))))'/></resource> <resource><xsl:value-of select='url:toString(uri:toURL(file:toURI(file:new(file:new(file:new(string(file:getParent(file:new(string($windchillSrcDir)))),"DevModules"),"Foundation"),"src"))))'/></resource> </volume> <volume> <type>javadoc</type> </volume> </library> </xsl:template> </xsl:stylesheet>
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4196318 Legacy Poster: Jess Holle (jessholle)
Also is there an update to saxon-resources8-9.zip for Saxon 8.9.0.2?
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4196330 Legacy Poster: Jess Holle (jessholle)
8.9.0.2 fixed the issue for me as well! Which leaves the other questions: 1) What changed in 8.9.0.2 (e.g. how can I determine if my other bug fix is in there other than re-testing)? 2) Is there an updated source package for 8.9.0.2?
RE: Static Java Function Problem - Added by Anonymous over 17 years ago
Legacy ID: #4197263 Legacy Poster: Michael Kay (mhkay)
The reason 8.9.0.2 fixes this is probably http://sourceforge.net/tracker/index.php?func=detail&aid=1660790&group_id=29872&atid=397617 which might have meant you were picking up Xalan instead of Saxon. The bugs that are fixed in 8.9.0.2 are those whose "group" is 8.9 and which carry the comment "fixed in 8.9.0.2". Furthermore, the release notes for 8.9.0.2 say: Apart from the build fixes, the new release incorporates all patches against bugs in group 8.9 raised up to the time of release, specifically: 1660975 Hyphens in regular expressions 1660794 unparsed-text() and MIME type XML 1660790 META-INF/services files 1660786 com.saxonica.Query needs -sa option 1660528 Java code generation API 1660148 Float/Double NaN in sum() and avg() 1659362 Extension functions on .NET 1659036 XQuery modules: function using schema-element() Release 8.9.0.2 corresponds to revision 85 in the latest8.9 branch in Subversion. There's no saxon-resources file for 8.9.0.2; if you want the fixed source code, you can get it from Subversion. Michael Kay
Please register to reply