xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremias Maerki <...@jeremias-maerki.ch>
Subject Re: Question on FOP extension automatic detection
Date Wed, 13 Feb 2008 19:08:55 GMT
On 13.02.2008 18:25:29 Andrejus Chaliapinas wrote:
> Jeremias,
> 
> > The example may indeed be a little restricted for your case. But still,
> > you can provide your own URIResolver and do whatever you want inside it.
> > The clue here is that you get a central place for the whole FOP that lets
> > you convert URIs to InputStreams. And how you set up these InputStreams
> > is entirely up to you. FOP doesn't care. At any rate, you don't pass any
> > objects to the FOUserAgent but to your own, custom-built URIResolver
> > which is set on the FopFactory.
> >
> 
> Could I add then custom URIResolver(s) to be activated/used only for
> particular prefixes?

You can only set one URIResolver. However, if you have multiple you can
write a URIResolver that uses the Composite pattern.

> Or should I implement resolve() method for each such
> different prefix and call some default URIResolver class in case of not
> special one is specified.

If you don't use the Composite pattern and only implement one
URIResolver you can listen to any number of prefixes you want.

> Is there any other dev doc on that? I've checked
> your recent SVG TestCase, but not sure if resolve() code should return null
> in default case.

No, URIResolver is an interface from JAXP. We just reuse the concept for
FOP. I'm sure you'll find examples on the net but it's really not that
difficult. Returning null shouldn't be a problem.

Just to give you the pattern:

public class MyURIResolver implements URIResolver {
    public Source resolve(String href, String base) throws TransformerException {
        if (href.startsWith("mystuff:")) {
            InputStream in = <whatever>
            return new StreamSource(in, href);
        } else {
            return null;
        }
    }
}


Jeremias Maerki


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


Mime
View raw message