[jdom-interest] [Fwd: Help: XSLT]

Laurent Bihanic laurent.bihanic at atosorigin.com
Wed Nov 6 02:44:58 PST 2002


> From: MerrilG at ibsplc.com
> The above mentioned import facility of xsl works when the XSLT is at
> the browser level.
> But 8-10 pages are hosted in the internet where we cannot specify the
> browser. People may use Netscape. For such users I do the XSLT at the
> server. Everything works fine except for the import tag. XSLT engine
> at the server thinks that the file is in the server's local directory.
> That is if I am using tomcat, the JVM's root directory would be
> tomcat's bin directory. So the XSLT searches for the particular file
> used in the import tag from the server's hard disk. Hence I always get
> the message in tomcat's console, that the file doesnot exist. I can
> hardcode the server address and url of the page, but that would not be
> right.
> How can we make the XSLT engine at the server  to use the url of the
> incoming request while parsing the xsl:import tag.

When interpreting xsl:import statements, if href contains a relative URI, the 
XSLT processor uses the base URI of the xsl:import node to resolve it into an 
absolute URI.
When being processed by the client navigator, the base URI of the xsl:import 
node is the one of the stylesheet and is an HTTP URL pointing at your web 
server/servlet container. On the other hand, if you specify the stylesheet as 
a file when running the transformation on the server, the base URI will be a 
file URL and the XSLT processor will not go through the web server/servlet 
container to retrieve the imported stylesheet.

Here are 2 ideas that may help resolving the problem:
1. Use an HTTP URL when specifying the main stylesheet (e.g. creating the 
stylesheet source using using the StreamSource(String) constructor).
2. Register your own implementation javax.xml.transform.URIResolver on the 
TransformerFactory to manually resolve the URIs.


More information about the jdom-interest mailing list