RE: [xsl] <xsl:include> using relative paths and Saxon 8

Subject: RE: [xsl] <xsl:include> using relative paths and Saxon 8
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 20 Jan 2006 17:05:23 -0000
Andrew was right. You aren't giving Saxon a URL here, all you're giving it
is an InputStream. Since Saxon has no idea where the InputStream came from,
it can't resolve anything relative to it. Do

xslSource.setSystemId(xsltUrl)

and you should be fine.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Chris Ward [mailto:cward@xxxxxxxxxxxxxxxxxxx] 
> Sent: 20 January 2006 16:49
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] <xsl:include> using relative paths and Saxon 8
> 
> 
> > 
> > It's likely you'll need to call setSystemId() on the 
> > StreamSource, or on the TransformerHandler (if you are using 
> > either of them).
> 
> 	Err... okay - will look into this.
> 
> > If not, post the part of your code that loads the stylesheet.
> 
> 	Here's an outline of what I'm doing 
> 
> 	- - - - - - - - - - - - - - - - - - - - - - - - - - - 
> 
>             URL url = new URL(xsltUrl);
>             URLConnection urlConn = url.openConnection();
> 
> 		InputStream is = urlConn.getInputStream();
> 		Source xslSource = new StreamSource(is);
> 
> 		TransformerFactory transFact =
> TransformerFactory.newInstance();
> 		Templates templates = transFact.newTemplates(xslSource);
> 
> 		Transformer transformer = templates.newTransformer();
> 
> 
> 		<snip>
> 
>             DocumentSource source = new DocumentSource(getDocument());
>             DocumentResult result = new DocumentResult();
>             try {
>                 transformer.transform(source, result);
>                 if (DEBUG) {
>                     System.out.println("transformer.transform()
> succeeded");
>                 }
>             }
>             catch (TransformerException ex) {
>                 // transformation failed somehow - should log this
>                 if (DEBUG) {
>                     System.out.println("transformer.transform()
> failed");
>                 }
>             }
>             // should I have a finally block?
>             this.transformedDocument = result.getDocument();
> 
> 	- - - - - - - - - - - - - - - - - - - - - - - - - - - 

Current Thread