[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL Import using relative location from within a j

Subject: Re: XSL Import using relative location from within a jar.
From: "Abel Braaksma (online)" <abel.online@xxxxxxxxx>
Date: Thu, 31 May 2007 13:38:26 +0200 (CEST)
Re:  XSL Import using relative location from within a j
If I understand your query correctly, you have a stylesheet that is
INSIDE a jar, which is compiled and runs with Xalan. From that
stylesheet you want to access a stylesheet OUTSIDE the jar, on the
"normal" filesystem.

Using absolute paths, this will be easy, just use the file: scheme
or the http: scheme, depending on ways available to you.

But I reckon that you want it relative to the base URI of the jar
file. MK already suggested you use your own URIResolver, which is
easy enough. Unfortunately you cannot do something like:

<xsl:import href="concat(system-property('jar-base'),
'../../mystyle.xslt')" />

because the @href attribute is not an AVT.

Another solution you might try if you don't feel confident about the
URIResolver method, is something I did to resolve MSXML-xslt
relative path problems: operate on the DOM of the XSLT before you
compile it. The solution is straightforward:

   1. Search the DOM tree for any xsl:import/include elements under
the root.
   2. Manipulate each @href attribute such that it's path becomes
absolute based on the relative path it provides, calculated from
the location of the jar.
   3. Compile the changed XSLT DOM.

Step 2 can be done easily using the URI or URL methods that Sun's
java provides by default to resolve a path relative to a given base
path (which is the jar-path of course).

Obviously, this is a less straightforward way then using the
URIResolver method. I only used it in the past because Javascript
does not offer a way to supply a custom URIResolver to an XSLT
processor.

Cheers,
-- Abel Braaksma


> Hello All,
> I have a stylesheet that exists within a jar.  Is there a way to
> write a
> relative href which points to a url outside of the jar?
>
> Example: bar.xsl exists in: com.company.foo.bar.xsl
> location of xsl I wish to import:
> ../../../user-defined-xsl/import_this_xsl.xsl  (the user-defined-xsl
> directory is on the same level as the jar file).
>
> ...
> <xsl:import href="../../../user-defined-xsl/import_this_xsl.xsl"/>
> ...
>
> Gives an exception.  I am using Xalan.
>
> Thanks.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.