【发布时间】:2010-09-20 11:59:32
【问题描述】:
我有一个包含 XSLT 转换的 Java maven 项目。我按如下方式加载样式表:
TransformerFactory tFactory = TransformerFactory.newInstance();
DocumentBuilderFactory dFactory = DocumentBuilderFactory
.newInstance();
dFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
ClassLoader cl = this.getClass().getClassLoader();
java.io.InputStream in = cl.getResourceAsStream("xsl/stylesheet.xsl");
InputSource xslInputSource = new InputSource(in);
Document xslDoc = dBuilder.parse(xslInputSource);
DOMSource xslDomSource = new DOMSource(xslDoc);
Transformer transformer = tFactory.newTransformer(xslDomSource);
stylesheet.xsl 有许多语句。这些似乎导致问题,当我尝试运行我的单元测试时,我收到以下错误:
C:\Code\workspace\app\dummy.xsl; Line #0; Column #0; Had IO Exception with stylesheet file: footer.xsl
C:\Code\workspace\app\dummy.xsl; Line #0; Column #0; Had IO Exception with stylesheet file: topbar.xsl
XSLT 中的 include 语句是相对链接
xsl:include href="footer.xsl"
xsl:include href="topbar.xsl"
我已经尝试过试验并将其更改为以下内容 - 但我仍然收到错误。
xsl:include href="xsl/footer.xsl"
xsl:include href="xsl/topbar.xsl"
有什么想法吗?非常感谢任何帮助。
【问题讨论】: