Re: Referring to a image file in a JAR file
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
RE: Referring to a image file in a JAR file
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/
RE: Referring to a image file in a JAR file
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 _ If It Exists, You'll Find it on SEEK. Australia's #1 job site http://clk.atdmt.com/NMN/go/157639755/direct/01/
Re: Referring to a image file in a JAR file
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 2010/7/21 Bernard Giannetti thebernmeis...@hotmail.com: Hi, I am trying to refer to a graphic file within a JAR file. The JAR file contains the application which is being executed along with the aforementioned graphic file. The application is launched via JNLP - so not sure if that effects what I am trying to do. If the JAR file is myapp.jar and the graphic is say image.svg then the tag fo:external-graphic src=file://myapp.jar!/image.svg content-width=8 content-height=8 results in the error Error with opening URL 'file://myapp.jar!/image.svg' I have tried different variations on the src attribute, say file:/// and then also url('/image.svg') but with similar errors. Is it possible to reference an image file within the same JAR as the application? Thanks in advance, Bernard. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
RE: Referring to a image file in a JAR file
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 _ Need a new place to live? Find it on Domain.com.au http://clk.atdmt.com/NMN/go/157631292/direct/01/
Re: Referring to a image file in a JAR file
No URIResolver should be necessary in this case. I think you simply need to add jar: in front and it should work, i.e.: jar:file://myapp.jar!/image.svg On 22.07.2010 03:05:42 Bernard Giannetti wrote: 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 _ Need a new place to live? Find it on Domain.com.au http://clk.atdmt.com/NMN/go/157631292/direct/01/ Jeremias Maerki - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org