Thanks Peter, for opening a new line of inquiry. The solution I came up with is not unlike Michael's recommendation as forwarded by DaveP.
What I did: Got real path (in class that initiates transformation): ServletContext ctx = servlet.getServletContext(); String cssFileName = ctx.getRealPath("/css/nrd.css"); Passed it to the Transformer: trans.setParameter("cssFile", cssFileName); Then added param at top of stylesheet, and used it in place: <xsl:param name="cssFile" select="'passedIn'"/> <link rel="stylesheet" type="text/css" href="{$cssFile}"/> Thanks to all for helpful pointers. Best, William BC Crandall bc.crandall [around] earthlink.net ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: 12 July 2004 1:18 AM Subject: RE: Finding CSS files in webapp > Xalan or Saxon have no 'base' from which to determine > the context for the css file, so you'll have to use > an absolute file reference from the stylesheet. > > Came up on the Saxon list this week. > Its for the document() function, but the same logic applies. > > HTH DaveP > > <quote> > > It appears that I must use a full path when using the > > xsl:result-document command from a saxon servlet. > > > > For example: <xsl:result-document href="file:/c:/mywebdir/myfile.htm" > > format="web"> > > > > rather than: <xsl:result-document href="file:/../../myfile.htm" > > format="web"> > > > > Is this true, or is it possible to use a relative path? > > Although it's possible in principle to use a relative path, this isn't > likely to be convenient in a servlet environment. Any relative URI is > resolved relative to the base URI of the principal output document, which in > the servlet case is going to the servlet output streat, which doesn't have a > meaningful URI. You could, when you allocate the principal output > destination, give it an arbitrary URI for this purpose: > > ServletOutputStream out = res.getOutputStream(); StreamResult tout = new > StreamResult(out); tout.setSystemId("file:/c:/some/uri/"); > transformer.transform(new StreamSource(sourceFile), tout); > > However, I'm wondering what you're actually trying to do here. Where do you > want to put the extra output files? Is it a location associated with the > individual end user, or a location associated with the source document, or > what? Are you trying to split the source document into multiple result > documents the first time it is accessed, and cache the results for later > use? Do you actually want to serialize the multiple output documents to > disk, or do you really want them in (application or session) memory? > > > Also, there is no > > 'c:' on Unix\Linux, so would I use something like > > 'href=file://mywebdir/myfile.html' ?? > > I think the correct syntax is file:///usr/dir/file.xml to reference the UNIX > file /user/dir/file.xml > > > > I'm new to the Servlet environment.. I'm not sure how to obtain the > > full path if I'm running my Servlet on a hosted machine. Do I have to > > ask the host provider and hard code the path or is there a dynamic way > > to do this? > > > > If you're running on a hosted machine then you'll have to write the files to > a directory where the servlet has write permission. A Java call such as > > getServletContext().getRealPath(source); > > will give you path names to files within the directory structure visible to > users via a browser - it's not clear whether you want the XML files you > generate to be directly accessible to users or not. > > Michael Kay > </quote> > > -- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]