Setting the base URI for resolving relative URIs (in xsl:include)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting the base URI for resolving relative URIs (in xsl:include)

Florent Georges
  Hi

  I'm using Saxon from the JAXP API.  Here is how:

    public void transform(String xslFilePath) {
        TransformerFactoryImpl tfactory =
            (TransformerFactoryImpl)TransformerFactory.newInstance();
        setFactoryConfiguration(tfactory);

        InputStream xsl_InputStream = new BufferedInputStream(
                                        new FileInputStream(
                                          new File(xslFilePath)));
        StreamSource xslSource = new StreamSource(xsl_InputStream);

        Transformer transformer = tfactory.newTransformer(xslSource);

        ...
    }

  The current directory is different from the directory
where is the XSLT file.  In the same directory, there are
other XSLT files included by 'xsl:include', whose the 'href'
is relative, like "./myfile.xsl".

  Unfortunately, Saxon doesn't find the included files.  Do
I have to write a URIResolver?  Is there some way to set the
base directory for resolving URIs?

  PS: I'm not reduced to use the JAXP API, I can use Saxon
particularities if needed.

  Thanks,

--drkm



















       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Setting the base URI for resolving relative URIs (in xsl:include)

Michael Kay
The simplest solution is to let Saxon create the streams, just do

 StreamSource xslSource = new StreamSource(new File(xslFilePath));

If you prefer to supply a stream, you should do setSystemId() on the
StreamSource object to supply a base URI.

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of drkm
> Sent: 08 November 2005 12:21
> To: Saxon Help SF list
> Subject: [saxon] Setting the base URI for resolving relative
> URIs (in xsl:include)
>
>   Hi
>
>   I'm using Saxon from the JAXP API.  Here is how:
>
>     public void transform(String xslFilePath) {
>         TransformerFactoryImpl tfactory =
>             (TransformerFactoryImpl)TransformerFactory.newInstance();
>         setFactoryConfiguration(tfactory);
>
>         InputStream xsl_InputStream = new BufferedInputStream(
>                                         new FileInputStream(
>                                           new File(xslFilePath)));
>         StreamSource xslSource = new StreamSource(xsl_InputStream);
>
>         Transformer transformer = tfactory.newTransformer(xslSource);
>
>         ...
>     }
>
>   The current directory is different from the directory
> where is the XSLT file.  In the same directory, there are
> other XSLT files included by 'xsl:include', whose the 'href'
> is relative, like "./myfile.xsl".
>
>   Unfortunately, Saxon doesn't find the included files.  Do
> I have to write a URIResolver?  Is there some way to set the
> base directory for resolving URIs?
>
>   PS: I'm not reduced to use the JAXP API, I can use Saxon
> particularities if needed.
>
>   Thanks,
>
> --drkm
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ______________________________________________________________
> _____________
> Appel audio GRATUIT partout dans le monde avec le nouveau
> Yahoo! Messenger
> Téléchargez cette version sur http://fr.messenger.yahoo.com
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App
> Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Setting the base URI for resolving relative URIs (in xsl:include)

Florent Georges
Michael Kay wrote:

> The simplest solution is to let Saxon create the streams, just do

>  StreamSource xslSource = new StreamSource(new File(xslFilePath));

  As simple as that :-).  Work like a charm, many thanks,

--drkm





















       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help