Is anyone aware of URIResolver issues with included stylesheets?
If no resolver is specified stylesheets that include other stylesheets default to the jboss bin directory which is not good so I've created a custom URIResolver to load up included stylesheets
transformerFactory.setURIResolver(
new URIResolver() {
public Source resolve(String href,String base) {
StreamSource ss = null;
try {
ss = new StreamSource(new StringReader(new String(
org.apache.commons.io.IOUtils.toByteArray(
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("com/company/xsl/DateTemplate.xsl")))));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ss;
}
}
);
The stylesheet is loaded correctly so that is not the issue. The SteamSource is fine. ( I know the StreamSource definition is not the best - it's only there for testing). I've also tried:
ss = new StreamSource(
Thread.currentThread().getContextClassLoader()
.getResourceAsStream("com/company/xsl/DateTemplate.xsl");
However I get an exception:
java.lang.NullPointerException
at com.icl.saxon.style.XSLGeneralIncorporate.getIncludedStyleSheet(XSLGeneralIncorporate.java:104)
at com.icl.saxon.style.XSLStyleSheet.spliceIncludes(XSLStyleSheet.java:421)
at com.icl.saxon.style.XSLStyleSheet.preprocess(XSLStyleSheet.java:346)
at com.icl.saxon.PreparedStyleSheet.setStyleSheetDocument(PreparedStyleSheet.java:176)
at com.icl.saxon.PreparedStyleSheet.prepare(PreparedStyleSheet.java:133)
at com.icl.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:127)
at com.icl.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:79)
Anyone come across this problem?
config:
jboss 3.2.5
java 1.4.2_05
winxp pro
TIA
Oz