Thanks to all...managed to sort it out! For future reference:
1) I found that I needed to set my URIResolver class in two places - foUserAgent.setURIResolver() and saxTransformerFactory.setURIResolver(). 2) The XSL I used to refer to my image (in the same jar file as the Java code, in img/myImage.svg) is <fo:external-graphic src="url(''img/myImage.svg)" content-width=... /> 3) The URIResolver::resolve went something like this: public Source resolve( String href, String base ) throws TransformerException { if( "img/myImage.svg".equals( href ) ) return new StreamSource( getClass().getClassLoader().getResourceAsStream( "img/myImage.svg" ); return null; } Thanks again for all your help! > From: tvtre...@nepatec.de > Date: Fri, 23 Jul 2010 13:48:34 +0200 > Subject: Re: Referring to a image file in a JAR file > To: fop-users@xmlgraphics.apache.org > > Hi, > > since the jar with our images was on the classpath we could reference > the image directly: > > <fo:external-graphic src="urn:some_logo.gif"/> > > -> "urn:" was the trigger for us in our resource resolver... > > Regards, > ToM > > 2010/7/22 Bernard Giannetti <thebernmeis...@hotmail.com>: > > I already have a URIResolver implemented to resolve the something such as > > > > <xsl:include href="pagesetup.xsl" /> > > > > which is what the Javadoc says it's used for: > > > > http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/javax/xml/transform/URIResolver.html > > > > Unfortunately, the <fo:external-graphic src="file://myapp.jar!/image.svg" > > content-width=8" content-height="8"> does not trigger the call to my URI > > resolver. I have tried src=url(....) etc with no luck. So either I've got > > the wrong format of the URL or it cannot be done this way. > > > > I don't see how to use xls:include, xsl:import and document (as per the > > Javadoc) to refer to the graphic file. In your example, did you refer to > > images using fo:external-graphic or using some other tag? > > > > The other thing I noticed is I set my URIResolver on the TransformerFactory: > > > > SAXTransformerFactory saxTransformerFactory = > > (SAXTransformerFactory)TransformerFactory.newInstance(); > > saxTransformerFactory.setURIResolver( myURIResolver ); > > > > instead of on the foUserAgent which you did...so dunno if that makes a > > difference. > > > > > >> Date: Wed, 21 Jul 2010 17:16:03 +0200 > >> Subject: Re: Referring to a image file in a JAR file > >> To: fop-users@xmlgraphics.apache.org > >> > >> Hi, > >> > >> we needed exactly that and implemented our own "ResourceResolver" for > >> that. > >> You can register it like the following: > >> > >> //Register a custom resolver > >> foUserAgent.setURIResolver(new ClasspathResourceResolver()); > >> > >> //The clas has to implement the URIResolver > >> public class ClasspathResourceResolver implements URIResolver { > >> > >> //you overwrite the resolve method > >> public InputStream resolve(String uri){ > >> > >> //Resolves the path to a resource in the classpath (since that jar > >> should be in the classpath > >> this.getClass().getResourceAsStream(uri); > >> > >> Regards, > >> ToM > > > > ________________________________ > > Find it on Domain.com.au Need a new place to live? > > --------------------------------------------------------------------- > To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org > For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org > _________________________________________________________________ New, Used, Demo, Dealer or Private? Find it at CarPoint.com.au http://clk.atdmt.com/NMN/go/206222968/direct/01/