开发者

XSL import causing FileNotFoundException in web application

开发者 https://www.devze.com 2023-02-05 07:25 出处:网络
I have a simple web application under websphere5. Under appDir\\WEB-INF\\classes\\ I have these files:

I have a simple web application under websphere5. Under appDir\WEB-INF\classes\ I have these files:

  • main.xslt
  • templates.xslt

main.xslt contains the instruction

<xsl:import href="templates.xsl" />

but the application fails when main.xslt is used in Java code. How should I specify the path to imported XSL files if they all are in the same folder (WEB-INF\classes\)?

Text of exception:

java.io.FileNotFoundException: d:\Program Files\WebSphere\AppServer1\templates.xsl (The system cannot find the file specif开发者_Python百科ied. )


You need to provide a custom uri-resolver to process the includes. In a web application, there's no guarantee that a filesystem is accessible, as you could be running out of a WAR file. Take a look at the javax.xml.transform.URIResolver interface and Transformer.setURIResolver()


Depending on how you loaded the main.xsl, you may need to set the SystemID property, so that it can resolve the relative path.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号