I originally used ApplyTag for xml/xslt transformation on VisualAge test environment and it worked fine. After I changed to StyleTag, I have to add the whole path, starting from c: drive root, to the file parameters, as "/Program Files/IBM/VisualAge for Java/ide/project_resources/IBM WebSphere Test Environment/hosts/default_host/default_app/web/header.xslt" instead of "header.xslt", otherwise, it won't find the file. I tried to change the code like ApplyTag, and it works fine. So, I wonder why you change the code on StyleTag. Do you have any reason for the change? The change I made on StyleTag is as follows (in StyleTag.getSource(Object): /* try { URL url = URLHelper.createURL( (String) source, pageContext ); //return new StreamSource(url.toExternalForm()); return new StreamSource(url.openStream(), url.toExternalForm()); */ ServletContext context =pageContext.getServletContext(); InputStream stream=context.getResourceAsStream((String)source); return new StreamSource(stream); /* } catch (IOException e) { throw new JspException("Bad URL:"+source + ". Exception: " + e.getMessage() ); } */ The part I comment out is the original code. I appreciate if you can take a look and let me know your thoughts. Margaret
Is ../default_host/default_app/web the directory that contains the WEB-INF directory and the WEB-INF/web.xml file? If so, try changing your XSLT document to "/header.xslt". All web-context relative URIs should start with "/" if they are meant to be relative to the web root. Let me know if that fixes it or if there is still a problem. James
James, Thanks for the prompt response. I don't have web.xml file and I put xtags.tld file under ../default_host/default_app/web/jakarta-taglibs/Web-inf/ and I specify the file location as <%@taglib uri="/jakarta-taglibs/Web-inf/xtags.tld" prefix="xsl" %> on the first line of my jsp file. I hope the setting is OK. Actually it runs well, only thing is that I need specify the whole physical path. I run the code as you suggested, I got NullPointerException at StyleTag.getSource(java.lang.Object). It can not find the file specified. Do you have a reason for changing the code as mentioned earlier? Thanks Margaret
Because if your URL starts with a '/' then the code should use pageContext.getServletContext().getResource( uri );. Look at the implementation of URLHelper.getResourceURL() which is called via the getSource() method;
I'm assuming that the resolution was to prefix your stylesheet or XML source file with "/". <xtags:style xsl="/foo.xsl"> So I'm marking this bug as resolved.