RE: [xsl] How do you use the URIResolver interface to find xsl templates in a WAR base application

Subject: RE: [xsl] How do you use the URIResolver interface to find xsl templates in a WAR base application
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 23 Apr 2002 15:14:58 +0100
It looks to me as if you are passing a String containing a filename to the
StreamSource constructor. It should be a String containing a URI. Try using
new StreamSource(new File(xx)) instead.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Onaindia,
> Juan
> Sent: 23 April 2002 14:50
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: [xsl] How do you use the URIResolver interface to find xsl
> templates in a WAR base application
>
>
> Hello,
>
> In the middle of converting existing applications to a WAR deployment
> environment, I have come up with the problem that during the
> transformation
> (in Java) the transformer tries to find the stylesheets base
> on the root of
> the application server in my case WebSphere.
> I have been trying to use the URIResolver interface to resolve this by
> passing the document root and publicId.
> The path of the file is correct but I still get the following
> exception:
>
> javax.xml.transform.TransformerConfigurationException:
>
> File "C:\Program Files\IBM\Application
> Developer\workspace\PositionControlFormsWeb\webApplication\WEB
> -INF\xsl\PCFMe
> taArea.xsl" not found
>
> I appreciate if someone could HELP me with this issue.
>
> Here is the code that I am using to do the transformation:
>
> final String documentRoot =
> getServletConfig().getServletContext().getRealPath("");
>
> TransformerFactory tFactory = TransformerFactory.newInstance();
> DIURIResolverImpl resolver = new DIURIResolverImpl(documentRoot);
> tFactory.setURIResolver(resolver);
>
> Transformer transformer = tFactory.newTransformer(new StreamSource(new
> FileInputStream(xslFilePath)));
>
> transformer.setOutputProperty(OutputKeys.METHOD, "html");
> transformer.setOutputProperty(OutputKeys.INDENT, "yes");
> // pass a parameter to the XSLT stylesheet
> transformer.setParameter("rootDir", documentRoot);
> transformer.transform(new StreamSource(doc), new StreamResult(out));
>
>
> The DIURIResolverImpl source code:
>
> import java.net.URL;
> import javax.xml.transform.URIResolver;
> import javax.xml.transform.TransformerException;
> import javax.xml.transform.Source;
> import javax.xml.transform.stream.StreamSource;
>
> public class DIURIResolverImpl implements URIResolver
> {
> 	private String docRoot;
>
> 	public DIURIResolverImpl(String documentRoot)
> 	{
> 		docRoot = documentRoot;
> 	}
> 	public Source resolve(String href, String base) throws
> TransformerException
> 	{
> 		try
> 		{
> 			return new StreamSource(docRoot + href);
> 		}
> 		catch (Exception e)
> 			{
> 			throw new TransformerException(e);
> 		}
> 	}
> }
>
> Once again, I appreciate any input.
>
> Thanks,
>
> Juan Onaindia
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread