Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » accessing resources from jar hosted in a plugin
accessing resources from jar hosted in a plugin [message #80147] Fri, 05 January 2007 10:37 Go to next message
David Beaurpere is currently offline David BeaurpereFriend
Messages: 15
Registered: July 2009
Junior Member
hi,

i am writing a plugin that requires some APIs which i hosted in a
separate binary plugin (along with every other dependency required)

that API works by applying xslt transformations and ship the required
xsl file within its own jar.

Luckily enough the the API was written in a way compatible with the
bundle classloaders and is able to retrieve the content of those xsl
files (by that i mean that it uses
"ClassLoader.getResourceAsStream(...)" instead of
"ClassLoader().getResource(...).openStream()" which doesn't work)

however once the xsls are fed to xalan they cannot be compiled because
the import statements cannot be resolved.

Note that the xsd files, imported and otherwise, are store together in
the same jar.

i have tried to switch the <xsd:import> statements with xml includes but
got the same result so it looks like the xml parser do not have better luck.

I have copied the error that i am getting.

Is there any thing that i can do?

====================
FINE: Transforming WSDL definition using XSL stylesheet
com/iona/soa/policies/soap11.xsl
ERROR:
'C:\eng\eclipse_3.2GA\eclipse\com\iona\soa\policies\inc_util ity_templates.xsl
(The system cannot find the path specified)'
FATAL ERROR: 'Could not compile stylesheet'
====================

thanks,
d.
Re: accessing resources from jar hosted in a plugin [message #80163 is a reply to message #80147] Fri, 05 January 2007 13:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

So, to clarify the problem, your issue is that you have a couple of stylesheets (xslt1 and xslt2) and that xslt1 uses xsl:import xslt2? And that it defaults to trying to load that as a file?

You probaly need to look at the URIResolver ( http://xml.apache.org/xalan-j/apidocs/javax/xml/transform/UR IResolver.html) which is supposed to be used to translate a request into a source location. You could return e.g. a StreamSource. The code will look something like:

public class JARURIResolver implements URIResolver {
 Source resolve(java.lang.String href, java.lang.String base) {
  return new StreamSource(getClass().getResourceAsStream(href));
 }
}
  :
  :
Transformer transformer = ...
transformer.setURIResolver(new JARURIResolver())


Or something similar to the above. Note this is all off-the-top-of-my-head and I've not tested the idea, but it should give you the right direction to start following. You'll almost certainly need to do extra processing of either the href or base (e.g. putting a / on the front of the href value) but the idea should be sound in principle.

I'm surprised that Xalan doesn't provide something for this already :-)

Alex.
Re: accessing resources from jar hosted in a plugin [message #80178 is a reply to message #80163] Fri, 05 January 2007 14:00 Go to previous message
David Beaurpere is currently offline David BeaurpereFriend
Messages: 15
Registered: July 2009
Junior Member
:))

i am in the process of trying just that (have a much better feeling
about it now though)

thanks,
d.

Alex Blewitt wrote:
> So, to clarify the problem, your issue is that you have a couple of stylesheets (xslt1 and xslt2) and that xslt1 uses xsl:import xslt2? And that it defaults to trying to load that as a file?
>
> You probaly need to look at the URIResolver ( http://xml.apache.org/xalan-j/apidocs/javax/xml/transform/UR IResolver.html) which is supposed to be used to translate a request into a source location. You could return e.g. a StreamSource. The code will look something like:
>
>
> public class JARURIResolver implements URIResolver {
>  Source resolve(java.lang.String href, java.lang.String base) {
>   return new StreamSource(getClass().getResourceAsStream(href));
>  }
> }
>   :
>   :
> Transformer transformer = ...
> transformer.setURIResolver(new JARURIResolver())
> 

>
> Or something similar to the above. Note this is all off-the-top-of-my-head and I've not tested the idea, but it should give you the right direction to start following. You'll almost certainly need to do extra processing of either the href or base (e.g. putting a / on the front of the href value) but the idea should be sound in principle.
>
> I'm surprised that Xalan doesn't provide something for this already :-)
>
> Alex.
Previous Topic:servletcontext
Next Topic:Running Equinox as a standalone application
Goto Forum:
  


Current Time: Fri Apr 26 21:32:56 GMT 2024

Powered by FUDForum. Page generated in 0.03075 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top