Hello,

I'm customizing my XML response using with the XSLTResponseWriter using
"&wt=xslt&tr=transform.xsl". Because I have a few use-cases to support, I
wanted to break up the common bits and import/include them from multiple top
level xslt files, but it appears that the base directory of the transform is
the directory the application was launched in.

Inside my "transform.xsl" I have this, for example

<xsl:import href="common/image-links.xsl"/>


which results in stack traces such as (copied only the relevant bits).

Caused by: java.io.IOException: Unable to initialize Templates 'transform.xsl'

Caused by: javax.xml.transform.TransformerException: Had IO Exception
with stylesheet file: common/image-links.xsl
Caused by: java.io.FileNotFoundException: C:\dev\jboss-5.1.0.GA
<http://jboss-5.1.0.ga/>\bin\common\image-links.xsl

This appears to be caused by a lack of provided systemId on the StreamSource
of the xslt document I've requested. I've copied the relevant lines that I
believe are the root cause of the problem here for reference.

TransformFactory.getTemplates():line 105-6

final InputStream xsltStream = loader.openResource("xslt/" + filename);
result = tFactory.newTemplates(new StreamSource(xsltStream));


The "loader" variable is an instance of solr's ResourceLoader which has no
ability to provide the systemId to set on StreamSource to make relative
references work in the xslt. It seems like we need something along the lines
of

String systemId = loader.getResourceURL().toString() + "xslt/";
result = tFactory.newTemplates(new StreamSource(xsltStream, systemId));


I looked for a bug/patch and didn't see anything. Please let me know, if I
missed the patch or if there is another way to solve this problem (aside
from not using xsl:include or xsl:import).

Thanks in advance,

Brian

For reference...
http://onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=5
https://jira.springframework.org/secure/attachment/10163/AbstractXsltView.patch
(similar
bug that was in spring)

Reply via email to