Vincent --
You're creating your DOM source from an in-memory Node so XalanJ has no
way of knowing what the corresponding URL is so that it can resolve your
xsl:include statements. You need to identify the URL that is the base
for your WAR file, assuming that your href=".." values are relative to
the WAR.
Try something like:
String baseURL = getServletContext().getRealPath("/");
DOMSource ds = new DOMSource(btnView.getDynamicDom(), baseURL);
transformer.transform(ds, new StreamResult(response.getWriter()));
This assumes that your .war file gets exploded into the real file system
rather than being used directly. This is the way many servlet
containers work but I'm not sure about WebLogic.
If that doesn't work, you can always specify your own URI resolver that
would be used from your newTransformer(...) call. To do this, do
tf.setURIResolver(myResolver)
before your tf.newTransformer call.
HTH,
Gary
> -----Original Message-----
> From: Rycx, Vincent [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 16, 2002 5:30 AM
> To: [EMAIL PROTECTED]
> Subject: RE: stylesheet nor found when <xsl:include ...>
> target is within a JAR file...
>
>
> Hi,
>
> Thanks for your quick answer.
>
> What I'm trying to do is convert an XML to HTML using an XSLT
> stylesheet. My code is executed at runtime from a servlet :
>
> ---------------------------------------
> TransformerFactory tf = TransformerFactory.newInstance();
> URL xslUrl = sc.getResource(btnView.getDynamicStylesheet());
> Transformer transformer = tf.newTransformer(new
> StreamSource(xslUrl.openStream()));
> transformer.transform(new DOMSource(btnView.getDynamicDom()),
> new StreamResult(response.getWriter()));
> ---------------------------------------
>
> So it works from a DOM Document as source and a stylesheet
> (packaged in a war).
>
> My stylesheet is something like that (it includes other
> stylesheets, that's where my problem comes from). Can you
> force xalan to use other URI resolvers
> ?) :
>
> ---------------------------------------
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:include href="/includes_xsl/Header_N.xsl" />
> <xsl:include href="/includes_xsl/EnableDisableMenu.xsl" />
> <xsl:include href="/includes_xsl/EnableDisableField.xsl" />
>
> <xsl:template match="/">
>
> <html>
> <head>
> <title></title>
> [...]
> ---------------------------------------
>
> The stack trace contains a lot of nested exceptions :
>
> ---------------------------------------
> javax.xml.transform.TransformerConfigurationException:
> javax.xml.transform.TransformerConfigurationException:
> javax.xml.transform.TransformerException:
> javax.xml.transform.TransformerException: Had IO Exception
> with stylesheet
> file: /includes_xsl/Header_N.xsl
> at
> org.apache.xalan.processor.TransformerFactoryImpl.newTransform
> er(Transformer
> FactoryImpl.java:767)
> at
> weblogic.xml.jaxp.RegistrySAXTransformerFactory.newTransformer
> (RegistrySAXTr
> ansformerFactory.java:216)
> at
> be.btn.web.WebTransformer.sendResponse(WebTransformer.java:87)
> at
> be.btn.web.HttpControllerServlet.doView(HttpControllerServlet.
> java:370)
> at
> be.btn.web.HttpControllerServlet.doGet(HttpControllerServlet.java:250)
> at
> be.btn.web.HttpControllerServlet.doPost(HttpControllerServlet.
> java:127)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(Servle
> tStubImpl.java
> :265)
> at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(Servle
> tStubImpl.java
> :200)
> at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(W
> ebAppServletCo
> ntext.java:2456)
> at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRe
> questImpl.java
> :2039)
> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
<rest of stack trace omitted>
>
> -----Original Message-----
> From: Gary L Peskin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, 14 January, 2002 18:12
> To: [EMAIL PROTECTED]
> Subject: RE: stylesheet nor found when <xsl:include ...>
> target is
> within a JAR file...
>
> Vincent --
>
> There are two issues here. Once is the formation of the URL
> and the other is the classloader that that URL is handed to.
> I believe that Shane has recently done some work in cleaning
> up the URL processing. Can you please post a small sample
> XSLT file illustrating what you're trying to do, together
> with the error message and stack trace that you're receiving?
>
> Thanks,
> Gary
>
> > -----Original Message-----
> > From: Rycx, Vincent [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, January 14, 2002 4:05 AM
> > To: [EMAIL PROTECTED]
> > Subject: stylesheet nor found when <xsl:include ...> target
> > is within a JAR file...
> >
> >
> > Hi,
> >
> > I have what seems to me to be a pretty basic problem that
> > should already have been answered 1000 times, but I found no
> > match in the mailing list archive, so I post it myself...
> >
> > I'm using xalan at runtime in my web application. It is
> > packaged in a WAR file. Let's say I use main.xsl as
> > stylesheet. I create the SteamSource so that it can find my
> > main.xsl from the war. So everything OK so far.
> >
> > The problem is that main.xsl includes a few other .xsl and
> > they seems to be resolved by Xalan to file references. Of
> > course, it does find the xsl to include within the my war...
> >
> > Any solution to make xalan look for my includes through my war ?
> > Vincent.
> >
>