Relative resource paths for external graphics where uri resolution is affected by every render request context

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Relative resource paths for external graphics where uri resolution is affected by every render request context

Mark Gibson

Hi,

 

We have a Java application with embedded FOP using XSLT transformations to drive the document rendering.  I’m trying to see if it’s possible to specify external graphics URIs in the XML with a relative path that is only indirectly related to the baseURI.  I’m finding it hard to put in to words, so some examples may help …

 

baseURI = /base/path/

 

Relative URI in XML = images/myImage.png

 

Say we have two requests to render a document, the first associated with account X, and the second associated with account Y.  The full URIs for each request should resolve to …

 

X: /base/path/X/images/myImage.png

Y: /base/path/Y/images/myImage.png

 

I’ve looked through the documentation and found that I can override resource resolving by supplying a custom ResourceResolver when creating a new FopFactoryBuilder.  However, based on best practices, the FopFactory instance should be reused for successive renders.  So I cannot apply a render specific context (in this case, X or Y).

 

Does anyone know of a way or either supplying extra context to be used by a custom resolver for each individual render, or apply a different resource resolver per render?

 

Thanks

Mark

Reply | Threaded
Open this post in threaded view
|

RE: Relative resource paths for external graphics where uri resolution is affected by every render request context

Simon Steiner

Hi,

 

The custom resource resolver can be modified at runtime such as myresourceresolver.useX() to affect its operation.

 

Thanks

 

From: Mark Gibson [mailto:[hidden email]]
Sent: 02 July 2019 19:31
To: [hidden email]
Subject: Relative resource paths for external graphics where uri resolution is affected by every render request context

 

Hi,

 

We have a Java application with embedded FOP using XSLT transformations to drive the document rendering.  I’m trying to see if it’s possible to specify external graphics URIs in the XML with a relative path that is only indirectly related to the baseURI.  I’m finding it hard to put in to words, so some examples may help …

 

baseURI = /base/path/

 

Relative URI in XML = images/myImage.png

 

Say we have two requests to render a document, the first associated with account X, and the second associated with account Y.  The full URIs for each request should resolve to …

 

X: /base/path/X/images/myImage.png

Y: /base/path/Y/images/myImage.png

 

I’ve looked through the documentation and found that I can override resource resolving by supplying a custom ResourceResolver when creating a new FopFactoryBuilder.  However, based on best practices, the FopFactory instance should be reused for successive renders.  So I cannot apply a render specific context (in this case, X or Y).

 

Does anyone know of a way or either supplying extra context to be used by a custom resolver for each individual render, or apply a different resource resolver per render?

 

Thanks

Mark

Reply | Threaded
Open this post in threaded view
|

RE: Relative resource paths for external graphics where uri resolution is affected by every render request context

Mark Gibson

Thank you Simon.  I had considered that, but had wondered if there was a more inherently thread safe approach.  Thankfully, our system is going to be single threaded so this isn’t a big issue.

 

From: Simon Steiner <[hidden email]>
Sent: 02 July 2019 20:00
To: [hidden email]
Subject: RE: Relative resource paths for external graphics where uri resolution is affected by every render request context

 

Hi,

 

The custom resource resolver can be modified at runtime such as myresourceresolver.useX() to affect its operation.

 

Thanks

 

From: Mark Gibson [[hidden email]]
Sent: 02 July 2019 19:31
To: [hidden email]
Subject: Relative resource paths for external graphics where uri resolution is affected by every render request context

 

Hi,

 

We have a Java application with embedded FOP using XSLT transformations to drive the document rendering.  I’m trying to see if it’s possible to specify external graphics URIs in the XML with a relative path that is only indirectly related to the baseURI.  I’m finding it hard to put in to words, so some examples may help …

 

baseURI = /base/path/

 

Relative URI in XML = images/myImage.png

 

Say we have two requests to render a document, the first associated with account X, and the second associated with account Y.  The full URIs for each request should resolve to …

 

X: /base/path/X/images/myImage.png

Y: /base/path/Y/images/myImage.png

 

I’ve looked through the documentation and found that I can override resource resolving by supplying a custom ResourceResolver when creating a new FopFactoryBuilder.  However, based on best practices, the FopFactory instance should be reused for successive renders.  So I cannot apply a render specific context (in this case, X or Y).

 

Does anyone know of a way or either supplying extra context to be used by a custom resolver for each individual render, or apply a different resource resolver per render?

 

Thanks

Mark

Reply | Threaded
Open this post in threaded view
|

RE: Relative resource paths for external graphics where uri resolution is affected by every render request context

Simon Steiner

Hi,

 

The fopfactory isn’t thread safe so cant be used across threads.

 

Thanks

 

From: Mark Gibson [mailto:[hidden email]]
Sent: 03 July 2019 11:39
To: [hidden email]
Subject: RE: Relative resource paths for external graphics where uri resolution is affected by every render request context

 

Thank you Simon.  I had considered that, but had wondered if there was a more inherently thread safe approach.  Thankfully, our system is going to be single threaded so this isn’t a big issue.

 

From: Simon Steiner <[hidden email]>
Sent: 02 July 2019 20:00
To: [hidden email]
Subject: RE: Relative resource paths for external graphics where uri resolution is affected by every render request context

 

Hi,

 

The custom resource resolver can be modified at runtime such as myresourceresolver.useX() to affect its operation.

 

Thanks

 

From: Mark Gibson [[hidden email]]
Sent: 02 July 2019 19:31
To: [hidden email]
Subject: Relative resource paths for external graphics where uri resolution is affected by every render request context

 

Hi,

 

We have a Java application with embedded FOP using XSLT transformations to drive the document rendering.  I’m trying to see if it’s possible to specify external graphics URIs in the XML with a relative path that is only indirectly related to the baseURI.  I’m finding it hard to put in to words, so some examples may help …

 

baseURI = /base/path/

 

Relative URI in XML = images/myImage.png

 

Say we have two requests to render a document, the first associated with account X, and the second associated with account Y.  The full URIs for each request should resolve to …

 

X: /base/path/X/images/myImage.png

Y: /base/path/Y/images/myImage.png

 

I’ve looked through the documentation and found that I can override resource resolving by supplying a custom ResourceResolver when creating a new FopFactoryBuilder.  However, based on best practices, the FopFactory instance should be reused for successive renders.  So I cannot apply a render specific context (in this case, X or Y).

 

Does anyone know of a way or either supplying extra context to be used by a custom resolver for each individual render, or apply a different resource resolver per render?

 

Thanks

Mark