Mikhail
Mikhail

Reputation: 1613

XSL import causing FileNotFoundException in web application

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

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 specified. )

Upvotes: 6

Views: 2879

Answers (2)

Mads Hansen
Mads Hansen

Reputation: 66714

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

Upvotes: 3

Jim Garrison
Jim Garrison

Reputation: 86744

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()

Upvotes: 4

Related Questions