In that sense you can use the absoult path to find the file. First however you must
implement the URIResolver that you pass to the transformer. The URIResolver then uses
the ServletContext to resolve the actual location of the files on your app. server.
example:
public class ServletContextResolver implements URIResolver {private transient ServletContext context = null;
public ServletContextResolver(ServletContext context) {
this.context = context;
}/**
* Reslove location of file
*
* @param href The file where / is the root dir in the servlet context (eg. /WEB-INF)
* @param base
*/
public Source resolve(String href, String base) throws TransformerException {
StreamSource source = new StreamSource(context.getResourceAsStream(href));
return source;
}
}
Sten
Shane Curcuru wrote:
Acually, I'm pretty sure that's not correct. I'm not a JSP expert, but Xalan can happily take either relative or absolute URLs to a stylesheet (and can take file: or http: ones), both to start with and for include/import (and document()).
Note however that if you use a relative URL, then it has to be relative to where the original stylesheet was loaded from - and Xalan has to know where that is! MAke sure when you create a transformer from the XSL Source object that you call setSystemId() (or that you're using the String or File constructor version) and that when you say xsl:import the href is relative to where the original stylesheet lives.
The other question is, where does your JSP environment deploy this code to. I'm presuming that you can find where it's putting your stylesheets and java code, so you can just put the included/imported stylesheets in the same place or in a subdirectory thereof.
(This is a common question with server-hosted environments: the whole deployment to the live server environment can change pathing, and you need to understand how that works).
Note that I would definitely not suggest using absolute URLs when you deploy to a live production server unless you're positive they'll always work! 8-)
===== - Shane
<eof aka="mailto:[EMAIL PROTECTED]" .sig="Du sublime au ridicule il n'y a qu'un pas." />
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
