xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Souris <c...@fargonauten.de>
Subject URIResolver not called
Date Wed, 13 Feb 2008 13:49:48 GMT
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


---------------------------------------------------------------------
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