You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by ha...@daimler.com on 2012/11/19 17:25:28 UTC
using sling parts within a xslt to fetch images
Hi there,
I tried to use FOP not with the rewriter, because I need to use some extra configuration.
But now I get stooped at using images out of the DAM. My xslt is not able to serve the namespace
(<fo:external-graphic src="sling:/{$resource}/par/{local-name()}.img.png" width="100pt" height="100pt" />)
The namespace is declared at the header of the xslt. So there must be something to be set for using
sling-parts inside the xslt. Does anybody know how to do this?
My Java-Code
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
InputStream inputStream = new FileInputStream("C:\\dev\\cq\\resource\\xsl\\fop.xconf");
Configuration cfg = cfgBuilder.build(inputStream);
fopFactory.setUserConfig(cfg);
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(new File(xslSource)));
transformer.setParameter("resource", resource.getPath());
DOMSource domSource = new DOMSource(xml);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(domSource, res);
Thanks and
Kind regards
M. Sticker
If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
Re: using sling parts within a xslt to fetch images
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,
we don't have a uri resolver for this, so you have to go with a custom one.
Regards
Carsten
2012/11/28 <ha...@daimler.com>:
> Hi,
>
> I was looking for a proper URIResolver for my own FOP(1.1)-to-Sling(with CQ5) implementation.
> I thought there must be something, which covers all cases, but for now we use our own built URIResolver.
>
> And Yes, the src-attribute in the FO-Part was handled ... sure, because the URIResolver was not set.
> Maybe you can give me a hint, for using the right Resolver in future? Thanks
>
> Best regards
>
> Markus
>
> -----Ursprüngliche Nachricht-----
> Von: Carsten Ziegeler [mailto:cziegeler@apache.org]
> Gesendet: Dienstag, 27. November 2012 18:37
> An: users@sling.apache.org
> Betreff: Re: using sling parts within a xslt to fetch images
>
> Hi,
>
> I'm not sure I understand your problem, do you have a problem with a namespace not being declared or do you have a problem with the sling:
> url inside the src attribute not being handled?
>
> Carsten
>
> 2012/11/19 <ha...@daimler.com>:
>> Hi there,
>>
>> I tried to use FOP not with the rewriter, because I need to use some extra configuration.
>> But now I get stooped at using images out of the DAM. My xslt is not
>> able to serve the namespace (<fo:external-graphic
>> src="sling:/{$resource}/par/{local-name()}.img.png" width="100pt"
>> height="100pt" />) The namespace is declared at the header of the xslt. So there must be something to be set for using sling-parts inside the xslt. Does anybody know how to do this?
>>
>> My Java-Code
>>
>> FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
>>
>> DefaultConfigurationBuilder cfgBuilder = new
>> DefaultConfigurationBuilder();
>>
>> InputStream inputStream = new
>> FileInputStream("C:\\dev\\cq\\resource\\xsl\\fop.xconf");
>>
>> Configuration cfg = cfgBuilder.build(inputStream);
>>
>> fopFactory.setUserConfig(cfg);
>>
>> Fop fop =
>> fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
>>
>> TransformerFactory factory = TransformerFactory.newInstance();
>> Transformer transformer =
>> factory.newTransformer(new StreamSource(new File(xslSource)));
>>
>> transformer.setParameter("resource",
>> resource.getPath());
>>
>> DOMSource domSource = new DOMSource(xml);
>>
>> Result res = new SAXResult(fop.getDefaultHandler());
>> transformer.transform(domSource, res);
>>
>>
>> Thanks and
>>
>> Kind regards
>>
>> M. Sticker
>>
>>
>>
>> If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
>>
>
>
>
> --
> Carsten Ziegeler
> cziegeler@apache.org
>
> If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
>
--
Carsten Ziegeler
cziegeler@apache.org
AW: using sling parts within a xslt to fetch images
Posted by ha...@daimler.com.
Hi,
I was looking for a proper URIResolver for my own FOP(1.1)-to-Sling(with CQ5) implementation.
I thought there must be something, which covers all cases, but for now we use our own built URIResolver.
And Yes, the src-attribute in the FO-Part was handled ... sure, because the URIResolver was not set.
Maybe you can give me a hint, for using the right Resolver in future? Thanks
Best regards
Markus
-----Ursprüngliche Nachricht-----
Von: Carsten Ziegeler [mailto:cziegeler@apache.org]
Gesendet: Dienstag, 27. November 2012 18:37
An: users@sling.apache.org
Betreff: Re: using sling parts within a xslt to fetch images
Hi,
I'm not sure I understand your problem, do you have a problem with a namespace not being declared or do you have a problem with the sling:
url inside the src attribute not being handled?
Carsten
2012/11/19 <ha...@daimler.com>:
> Hi there,
>
> I tried to use FOP not with the rewriter, because I need to use some extra configuration.
> But now I get stooped at using images out of the DAM. My xslt is not
> able to serve the namespace (<fo:external-graphic
> src="sling:/{$resource}/par/{local-name()}.img.png" width="100pt"
> height="100pt" />) The namespace is declared at the header of the xslt. So there must be something to be set for using sling-parts inside the xslt. Does anybody know how to do this?
>
> My Java-Code
>
> FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
>
> DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
>
> InputStream inputStream = new
> FileInputStream("C:\\dev\\cq\\resource\\xsl\\fop.xconf");
>
> Configuration cfg = cfgBuilder.build(inputStream);
>
> fopFactory.setUserConfig(cfg);
>
> Fop fop =
> fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
>
> TransformerFactory factory = TransformerFactory.newInstance();
> Transformer transformer =
> factory.newTransformer(new StreamSource(new File(xslSource)));
>
> transformer.setParameter("resource",
> resource.getPath());
>
> DOMSource domSource = new DOMSource(xml);
>
> Result res = new SAXResult(fop.getDefaultHandler());
> transformer.transform(domSource, res);
>
>
> Thanks and
>
> Kind regards
>
> M. Sticker
>
>
>
> If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
>
--
Carsten Ziegeler
cziegeler@apache.org
If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
Re: using sling parts within a xslt to fetch images
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,
I'm not sure I understand your problem, do you have a problem with a
namespace not being declared or do you have a problem with the sling:
url inside the src attribute not being handled?
Carsten
2012/11/19 <ha...@daimler.com>:
> Hi there,
>
> I tried to use FOP not with the rewriter, because I need to use some extra configuration.
> But now I get stooped at using images out of the DAM. My xslt is not able to serve the namespace
> (<fo:external-graphic src="sling:/{$resource}/par/{local-name()}.img.png" width="100pt" height="100pt" />)
> The namespace is declared at the header of the xslt. So there must be something to be set for using
> sling-parts inside the xslt. Does anybody know how to do this?
>
> My Java-Code
>
> FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
>
> DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
>
> InputStream inputStream = new FileInputStream("C:\\dev\\cq\\resource\\xsl\\fop.xconf");
>
> Configuration cfg = cfgBuilder.build(inputStream);
>
> fopFactory.setUserConfig(cfg);
>
> Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
>
> TransformerFactory factory = TransformerFactory.newInstance();
> Transformer transformer = factory.newTransformer(new StreamSource(new File(xslSource)));
>
> transformer.setParameter("resource", resource.getPath());
>
> DOMSource domSource = new DOMSource(xml);
>
> Result res = new SAXResult(fop.getDefaultHandler());
> transformer.transform(domSource, res);
>
>
> Thanks and
>
> Kind regards
>
> M. Sticker
>
>
>
> If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
>
--
Carsten Ziegeler
cziegeler@apache.org