I'm using the AbstractXsltView and I'd like to use relative paths in my xsl:import. In the past I've accomplished this by setting a system ID to StreamSource objects upon their construction. Here's a patch to AbstractXsltView that accomplishes this (I've only tested running within a web container (Tomcat)):
(Are these new forums the place for patch submissions now?)Code:Index: AbstractXsltView.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/xslt/AbstractXsltView.java,v retrieving revision 1.12 diff -u -r1.12 AbstractXsltView.java --- AbstractXsltView.java 29 Jun 2004 12:09:43 -0000 1.12 +++ AbstractXsltView.java 12 Aug 2004 05:34:52 -0000 @@ -18,6 +18,7 @@ import java.io.BufferedOutputStream; import java.io.IOException; +import java.net.URL; import java.util.Iterator; import java.util.Map; @@ -168,7 +169,10 @@ logger.debug("Loading XSLT stylesheet from " + stylesheetLocation); } try { - return new StreamSource(stylesheetLocation.getInputStream()); + URL url = stylesheetLocation.getURL(); + String urlPath = url.toString(); + String systemId = urlPath.substring(0,urlPath.lastIndexOf('/')+1); + return new StreamSource(url.openStream(),systemId); } catch (IOException ex) { throw new ApplicationContextException("Can't load XSLT stylesheet from " + stylesheetLocation, ex);


Reply With Quote