Hi
 
My way to do this in WSAD and WebSphere is to ask for the proper stream from the web container and not to try to get it myself from the disk:
 
Stream xslStream = getServletContext().getResourceAsStream("/html/StockTemplate.xsl");
Source xslSource = new StreamSource(xslStream);
(*)
Transformer transformer = factory.newTransformer(xslSource);
 
(*) if your Xsl file imports/includes other Xsl files, you have to set properly here the systemId of your Xsl source before using it:

xslSource.setSystemId(getServletContext().getResource("/html/StockTemplate.xsl"));

-----Original Message-----
From: Bob Lee [mailto:[EMAIL PROTECTED]
Sent: 29 April 2004 17:45
To: [EMAIL PROTECTED]
Subject: How to get the XSL file using relative path?

hi,

I have a xsl file. I need to use Transformer to process this xsl source into a Transformer object. But it looks like I have to specify the full path for this XSL file. This is what I want to avoid because we do not want to change the file path manually once we deploy it to our production. Here is the codes. I appreciate it if anyone can give me some suggestions.

//ViewStock is my project name

File MyXsl = new File("C:/workspace/ViewStock/Web Content/html/StockTemplate.xsl");

//Setup XSLT

TransformerFactory factory = TransformerFactory.newInstance();

Transformer transformer = factory.newTransformer(new StreamSource(MyXsl));

 

thanks in advance,

Bob


Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs

Reply via email to