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 Marc Bleron <ma...@gdfsuez.com> on 2014/12/05 15:55:09 UTC

SVG image cache using a URIResolver?

Hi,

Using FOP 1.1 on Java 1.5

I have SVG images stored in a database (Oracle 11.2) which I want to include
in a PDF document.
To achieve that I've created a custom URIResolver listening to a specific
uri scheme, and used that uri as source for fo:external-graphics, e.g.

<xsl:template match="Object">
  <fo:block>
    <fo:external-graphic src="url('cache:/media/{@cache-id}')"
content-width="scale-to-fit" width="100%"/>
  </fo:block>
</xsl:template>

While transforming and rendering the output document, the URIResolver then
issues the corresponding query against the db using the cache-id value and
returns a StreamSource. That works fine.

The "problem" is that the URIResolver (and therefore the db) is called twice
when building the PDF document : once when transforming my input XML into FO
and another time when rendering the PDF from the FO.

My question is : is that intended behaviour? Isn't the caching mechanism
supposed to work in this situation?
Just want to be sure.

When using a FO object directly (identity transformation), the URIResolver
is called only once.

Thanks for any pointers.

Marc.



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


Re: SVG image cache using a URIResolver?

Posted by Marc Bleron <ma...@gdfsuez.com>.
Luis Bernardo <lmpmbernardo <at> gmail.com> writes:

> 
> 
> Probably the URI is validated during the XML/XSL to FO transformation, 
> and the validation requires a call -- you can check that by returning an 
> invalid response. In any case, the official input for FOP is FO and the 
> caching was implemented with that in mind.
> 
> You can tweak your URIResolver to not call the DB and just return an 
> "OK" response the first time it is called for a particular URI.
> 
> You can tweak your URI resolver

Thanks for your reply.

I'll probably move towards doing the XSLT transformation in a separate step
then. The source XML data is generated on database side so performing the
transformation to FO there is an option.

Note that I've only associated the URIResolver with the FOUserAgent and
*not* with the Transformer so I'm still wondering why the URIResolver is
invoked while doing the XSLT transformation.

Regards.



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


Re: SVG image cache using a URIResolver?

Posted by Luis Bernardo <lm...@gmail.com>.
Probably the URI is validated during the XML/XSL to FO transformation, 
and the validation requires a call -- you can check that by returning an 
invalid response. In any case, the official input for FOP is FO and the 
caching was implemented with that in mind.

You can tweak your URIResolver to not call the DB and just return an 
"OK" response the first time it is called for a particular URI.

You can tweak your URI resolver

On 12/5/14, 2:55 PM, Marc Bleron wrote:
> Hi,
>
> Using FOP 1.1 on Java 1.5
>
> I have SVG images stored in a database (Oracle 11.2) which I want to include
> in a PDF document.
> To achieve that I've created a custom URIResolver listening to a specific
> uri scheme, and used that uri as source for fo:external-graphics, e.g.
>
> <xsl:template match="Object">
>    <fo:block>
>      <fo:external-graphic src="url('cache:/media/{@cache-id}')"
> content-width="scale-to-fit" width="100%"/>
>    </fo:block>
> </xsl:template>
>
> While transforming and rendering the output document, the URIResolver then
> issues the corresponding query against the db using the cache-id value and
> returns a StreamSource. That works fine.
>
> The "problem" is that the URIResolver (and therefore the db) is called twice
> when building the PDF document : once when transforming my input XML into FO
> and another time when rendering the PDF from the FO.
>
> My question is : is that intended behaviour? Isn't the caching mechanism
> supposed to work in this situation?
> Just want to be sure.
>
> When using a FO object directly (identity transformation), the URIResolver
> is called only once.
>
> Thanks for any pointers.
>
> Marc.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>


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