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: URIResolver not called
Date Wed, 13 Feb 2008 15:51:14 GMT
I use a URIResolver with FOP all the time and I have no problems. In
your simple case, the URI resolution may never be invoked if you try
with a simple example. Furthermore, you should set the URIResolver on
the FopFactory so all URIs (not only URIs related to a rendering run)
are resolved through your URIResolver.

On 13.02.2008 14:49:48 Christoph Souris wrote:
> Hi,
> 
> I have a problem registering a URIResolver instance. According to the 
> "Embedding" manual I tried to register it at the FOUserAgent but that 
> did not work (it was not called).
> 
> I see 3 possible ways to do this (apart from the FopFactory):
> 
> (1) the FopUserAgent
> (2) the TransformerFactory
> (3) the Transformer itself
> 
> I tried all of these but only the 2nd option worked for my test case. 
> Here is some code which reproduces the problem. As you can see I am 
> using the 'projectteam' example (I only added an <xsl:import /> 
> statement to file 'projectteam.xsl'):
> 
> public static void main ( String[] _ ) throws Exception
> {
>    URIResolver resolver = new URIResolver() {
>      public Source resolve ( String href, String base ) {
>        throw new UnsupportedOperationException( "Not implemented!" );
>      }};
> 		
>    FopFactory fopFactory = FopFactory.newInstance();
>    FOUserAgent agent = fopFactory.newFOUserAgent();
>    agent.setURIResolver( resolver );
> 		
>    OutputStream sink = new FileOutputStream( "result.pdf" );
>    Fop fop = fopFactory.newFop( MimeConstants.MIME_PDF, agent, sink );
> 
>    Source src = new StreamSource(
>      App.class.getResourceAsStream( "/projectteam.xml") );
>    Result res = new SAXResult( fop.getDefaultHandler() );
> 
>    TransformerFactory transformerFactory =
>      TransformerFactory.newInstance();
>    transformerFactory.setURIResolver( resolver );
>    Transformer transformer = transformerFactory.newTransformer(
>      new StreamSource(
>        App.class.getResourceAsStream( "/projectteam.xsl" ) ) );
>    transformer.setURIResolver( xslfoJob.getURIResolver() );
>    transformer.transform( src, res );
> }
> 
> Only if the resolver is registered to the TransformerFactory it is 
> called during the transformation (the exception is thrown). Registering 
> at the agent (or the transformer) does not no matter if FOP version 0.93 
> or 0.94 is used.
> 
> I think I'm missing something very obvious -- can anyone give me a push?
> 
> 
> Thanks in advance,
> Christoph



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