Subject: Re: [xsl] 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) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSL Import using relative, Michael Kay | Thread | [xsl] value-of or apply-templates: , Kaz |
Re: [xsl] value-of or apply-templat, J. S. Rawat | Date | [xsl] xsl:element will not create a, N David Brown |
Month |