I think the problem is that you are opening the connection yourself. I think
if you hand the URL String to the XsltInputSource constructor, and let it
open the connection, then it will properly set the base. As it is, the source
can not see the URL, and thus does not know how to set the base.

tim.

> Hmm..
> 
> I am using the following code to read in the XSL. Its not the most efficient
> way..but it is how I am doing it. I am now starting to see that this must be
> the problem..although I am not sure why.
> 
> 
>   StreamSource xslStream = null;
>   StreamSource xmlStream = null;
>   String urlPrefix = request.getScheme() + "://" + request.getServerName() +
> request.getContextPath();
> 
>   try
>   {
>     URL url = new URL(urlPrefix + r.getXSL());
>     xslStream = new StreamSource(url.openConnection().getInputStream());
>   }
>   catch(Exception e)
>   {
>     e.printStackTrace(System.out);
>     System.out.println("Exception " + e.getMessage());
>   }
>   // Transform the xml output using the xsl stylesheet and the XALAN XSLT
>   // engine, placing the output stream of the transformation in the
>   // HttpServletResponse output stream.
> 
>   response.setContentType("text/html"); // always assume HTML output from
> this controller
> 
>   try
>   {
>     URL url = new URL(urlPrefix + r.getName() + "?jsessionid=" +
> request.getSession(true).getId());
>     xmlStream = new StreamSource(url.openConnection().getInputStream());
>     TransformerFactory tFactory = TransformerFactory.newInstance();
>     Transformer transformer = tFactory.newTransformer(xslStream);
>     transformer.transform(xmlStream, new
> StreamResult(response.getOutputStream()));
>   }
> 
> This works as far as getting the first XSL page, but the included XSL page
> in the XSL page is not working very well. It appears I need to somehow pass
> the root path or something? I took most of this code out of an example of
> how to use the TrAX api to transform a document. I figured by using URL's to
> read in the xsl AND jsp (to get XML output), it would allow me to locate XSL
> pages anywhere on the web and still get to them. Does it appear something is
> flawed in this approach (or should I say..if you know of a better way to
> make this work, please elaborate if you can).
> 
> 
> Thanks.
> 
> 
> > -----Original Message-----
> > From: Arved Sandstrom [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, February 13, 2001 1:07 PM
> > To: Orion-Interest
> > Subject: RE: Why xsl:include seems to try to find files in 
> > /Orion folder
> > and not web-app root?
> > 
> > 
> > It was an email from Matt Krevs.
> > 
> > I threw in:
> > 
> > File xsl = ...;     // the stylesheet as a java.io.File
> > XSLTInputSource stylesheet = new XSLTInputSource( new 
> > FileReader( xsl ) );
> > stylesheet.setSystemId( "file:" + xsl.getAbsolutePath() );
> > 
> > This works fine with Xalan 1.2.2.
> > 
> > Regards,
> > Arved Sandstrom
> > 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of 
> > Duffey, Kevin
> > Sent: Tuesday, February 13, 2001 4:29 PM
> > To: Orion-Interest
> > Subject: RE: Why xsl:include seems to try to find files in 
> > /Orion folder
> > and not web-app root?
> > 
> > 
> > I can't seem to find the email with the setSystemId(). Can you either
> > forward it to me, or show me how you did it so I can try it 
> > out. Where is
> > that set specifically?
> > 
> > Thanks.
> > 
> > 
> > > -----Original Message-----
> > > From: Arved Sandstrom [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, February 13, 2001 12:07 PM
> > > To: Orion-Interest
> > > Subject: RE: Why xsl:include seems to try to find files in 
> > > /Orion folder
> > > and not web-app root?
> > > 
> > > 
> > > I haven't looked at Saxon with respect to this particular 
> > > issue. However, I
> > > went and looked at my copy of Michael Kay's book a few days 
> > > ago, and he
> > > confirms the behaviour described in the spec. If you have 
> > > used SAXON in any
> > > other way, and/or followed Mike on the Mulberry XSLT mailing 
> > > list, you'll
> > > realize that here's a guy who is so up on XSLT that there is 
> > > no way that he
> > > would allow this not to work.
> > > 
> > > But, yeah, at the moment I'm guessing. :-) Also, there was 
> > the earlier
> > > suggestion to use setSystemId() on the stylesheet 
> > > XSLTInputSource; I tried
> > > that and it worked out fine for fixing this problem (with Xalan).
> > > 
> > > Regards,
> > > Arved Sandstrom
> > > 
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Tim Endres
> > > Sent: Tuesday, February 13, 2001 3:02 PM
> > > To: Orion-Interest
> > > Subject: RE: Why xsl:include seems to try to find files in 
> > > /Orion folder
> > > and not web-app root?
> > > 
> > > 
> > > Does Saxon solve this particular issue? If so, how?
> > > Thanks, tim.
> > > 
> > > > We have observed this behaviour with Xalan (1.2.x family) 
> > > both in and
> > > > outside of app servers. Xalan uses the "working directory", 
> > > according to
> > > > Java, as the base URI. Which is of course wrong.
> > > >
> > > > Dunno about Xalan2. Possibly fixed. In any case I'm 
> > > planning to switch
> > > over
> > > > to Saxon.
> > > >
> > > > Regards,
> > > > Arved Sandstrom
> > > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED]
> > > > [mailto:[EMAIL PROTECTED]]On Behalf Of 
> > Dan Cramer
> > > > Sent: Tuesday, February 13, 2001 4:54 AM
> > > > To: Orion-Interest
> > > > Subject: RE: Why xsl:include seems to try to find files in 
> > > /Orion folder
> > > > and not web-app root?
> > > >
> > > >
> > > > Check out the XSLT spec at 
> > > http://www.w3.org/TR/xslt#include. According to
> > > > the spec, in an <xsl:include> tag, a relative URI as the 
> > > value for the
> > > href
> > > > attribute should be interpreted as starting in the same 
> > > directory as the
> > > > including stylesheet.
> > > >
> > > > Example:
> > > >         assume that a stylesheet /www/xsl/A uses the tag: 
> > > <xsl:include href="B">,
> > > > then the XSLT engine should include the stylesheet /www/xsl/B.
> > > >
> > > > If this isn't what you're seeing, then your processor has a bug.
> > > >
> > > > This might help more than my suggestion before :-)
> > > > Dan Cramer
> > > > Chief Architect
> > > > Dynamic Resolve, LLC
> > > > Internet Solutions Consulting
> > > >
> > > > > -----Original Message-----
> > > > > From: [EMAIL PROTECTED]
> > > > > [mailto:[EMAIL PROTECTED]]On Behalf Of 
> > > Duffey, Kevin
> > > > > Sent: Monday, February 12, 2001 5:47 PM
> > > > > To: Orion-Interest
> > > > > Subject: Why xsl:include seems to try to find files in 
> > > /Orion folder and
> > > > > not web-app root?
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > > When I use the <xsl:include..> directive, it appears to look in
> > > > > server root
> > > > > dir, and not the web-app root its deployed in. I am not 
> > > quite sure if
> > > this
> > > > > is something to do with Orion, or if all servers operate in this
> > > > > manner and
> > > > > therefore its an error of the XSLT technology. 
> > > Or..perhaps its an error
> > > of
> > > > > the saxon library I am working with. Just wondering if 
> > > anyone working
> > > with
> > > > > Orion and XSL have seen this problem or not?
> > > > >
> > > > > Thanks.


Reply via email to