You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Steve Ebersole <st...@hibernate.org> on 2007/08/17 17:33:33 UTC

FOP + DocBook + img.src.path

I am having some difficulty getting fop-0.93 to work with DocBook in one very 
specific case.  I need to tell fop/docbook where to find images, so initially 
I tried setting this 'img.src.path' docbook xslt param.  This is set to a 
fully resolved file path.  Actually this works great on my linux box.  

And then a user on windows tried it:
java.net.MalformedURLException: unknown protocol: d
        at java.net.URL.<init>(URL.java:574)
        at java.net.URL.<init>(URL.java:464)
        at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:138)
        at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:638)
        at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:421)
        at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:395)
        at org.apache.fop.image.ImageFactory.loadImage(ImageFactory.java:190)
        at org.apache.fop.image.ImageLoader.loadImage(ImageLoader.java:56)
        at 
org.apache.fop.image.ContextImageCache.getImage(ImageFactory.java:432)
        at org.apache.fop.image.ImageFactory.getImage(ImageFactory.java:157)
        at 
org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:68)
        at org.apache.fop.fo.FObj.processNode(FObj.java:118)
        at 
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:321)
        at 
org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:185)
        at 
com.icl.saxon.output.ContentHandlerProxy.startElement(ContentHandlerProxy.java:119)
...

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=116150&postdays=0&postorder=asc&start=0

So that leaves me with the question of which is correct.  Is 'img.src.path' 
expected to be a URL, as fop believes?  

Also, in general since setting a single 'img.src.path' always seemed kind of 
limiting anyway, would it instead make sense to not rely on that and instead 
plugin in a URIResolver to find the images (this would obviously not work out 
for other docbook formats however)?  Via FOUserAgent.setURIResolver() I 
mean...  What else beside images is this URIResolver asked to resolve?

Thanks,
Steve

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: FOP + DocBook + img.src.path

Posted by Vincent Hennebert <vi...@anyware-tech.com>.
Hi Steve,

Steve Ebersole a écrit :
> I am having some difficulty getting fop-0.93 to work with DocBook in
one very
> specific case.  I need to tell fop/docbook where to find images, so
initially
> I tried setting this 'img.src.path' docbook xslt param.  This is set to a
> fully resolved file path.  Actually this works great on my linux box.
>
> And then a user on windows tried it:
> java.net.MalformedURLException: unknown protocol: d
<snip/>
> So that leaves me with the question of which is correct.  Is
'img.src.path'
> expected to be a URL, as fop believes?

Yes, see the documentation for the img.src.path parameter:
http://docbook.sourceforge.net/release/xsl/current/doc/fo/img.src.path.html
This is a prefix that will be added to your image paths and put in the
‘src’ parameter of the fo:external-graphic element, which is itself
expecting a URI. So you should specify something like
“file://d:path/to/the/images/” which I believe is the correct syntax for
specifying drive letters.
Note that a relative URI should also work: “../images/”. As this is
a URI you must use slashes even on Windows. Mind the final slash, which
is important for correct URI resolution.


> Also, in general since setting a single 'img.src.path' always seemed
kind of
> limiting anyway, would it instead make sense to not rely on that and
instead
> plugin in a URIResolver to find the images (this would obviously not
work out
> for other docbook formats however)?  Via FOUserAgent.setURIResolver() I
> mean...  What else beside images is this URIResolver asked to resolve?

Among other things the URIResolver is used to resolve paths to fonts, so
you can’t just override it like that. IIC this method is meant to be
used in server environments, where URI resolution is a bit special as
there might be some indirection mechanism.

You could define a custom URI scheme for images, and plug in
a corresponding URIResolver that would defer the resolution of other
URIs to the default one. But I’m not sure you really want that.
According to the documentation the prefix specified in ‘img.src.path’
won’t be added to absolute paths, so playing with that might be enough
for you.

You might also get further help on the docbook-apps mailing list.

HTH,
Vincent


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org