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 Bernard Giannetti <th...@hotmail.com> on 2013/09/29 08:23:24 UTC

Processing selected nodes...

Hi,
I'm using FOP, embedded in a desktop application, to create PDFs from a single data XML file using an XSLT file.
Say the data XML file is a list of items, for example:
<items>  <item>    apple  </item>  <item>    orange  </item>  <item>    water melon  </item>...</items>
I want to be able to tell the XSLT to only process specific items (say "apple" and "orange").
I've created a java.util.ArrayList and passed that to the transformer using setParameter( "theList", theList ).  In the XSLT, when I use <xsl:value-of select="$theList" />, I'll get in the output  [apple, orange].  Fair enough.
However, what I really want (I think) is to take the array and iterate over it, calling a template for each item.  Is this possible?
>From what I've managed to deduce from a lot of searching/reading is that it's possible even to pass in a Java object and somehow get XSLT to access that Java object.  I'm not sure if that is overkill for what I want to do, but I cannot even achieve processing a list of items one by one.

Thanks in advance,
Bernard. 		 	   		  

RE: Processing selected nodes...

Posted by Bernard Giannetti <th...@hotmail.com>.
FYI, I posted a question (and solution) at http://www.tek-tips.com/viewthread.cfm?qid=1719206.

From: thebernmeister@hotmail.com
To: fop-users@xmlgraphics.apache.org
Subject: Processing selected nodes...
Date: Sun, 29 Sep 2013 16:23:24 +1000




Hi,
I'm using FOP, embedded in a desktop application, to create PDFs from a single data XML file using an XSLT file.
Say the data XML file is a list of items, for example:
<items>  <item>    apple  </item>  <item>    orange  </item>  <item>    water melon  </item>...</items>
I want to be able to tell the XSLT to only process specific items (say "apple" and "orange").
I've created a java.util.ArrayList and passed that to the transformer using setParameter( "theList", theList ).  In the XSLT, when I use <xsl:value-of select="$theList" />, I'll get in the output  [apple, orange].  Fair enough.
However, what I really want (I think) is to take the array and iterate over it, calling a template for each item.  Is this possible?
>From what I've managed to deduce from a lot of searching/reading is that it's possible even to pass in a Java object and somehow get XSLT to access that Java object.  I'm not sure if that is overkill for what I want to do, but I cannot even achieve processing a list of items one by one.

Thanks in advance,
Bernard. 		 	   		   		 	   		  

RE: Processing selected nodes...

Posted by Bernard Giannetti <th...@hotmail.com>.
Thanks Tim, et al - I was thinking that since I was passing a parameter from my "FOP" code, this was something to do with FOP.


From: tom@hillcountrysoftware.com
To: fop-users@xmlgraphics.apache.org
Subject: RE: Processing selected nodes...
Date: Sun, 29 Sep 2013 16:54:47 -0500

While this is the wrong list, I don’t see anything in your request that cannot be done using relatively simple XSLT. I would invite you to post your question on the XML Forum at Tek-Tips, where I have answered XSLT questions for years.  That way, the answer might (might!) help someone else.  Registration is free, and it is absolutely the most spam-free environment you can imagine.http://www.tek-tips.com/threadminder.cfm?pid=426 Tom MorrisonHill Country Software From: Bernard Giannetti [mailto:thebernmeister@hotmail.com] 
Sent: Sunday, September 29, 2013 1:23 AM
To: fop-users@xmlgraphics.apache.org
Subject: Processing selected nodes... Hi, I'm using FOP, embedded in a desktop application, to create PDFs from a single data XML file using an XSLT file. Say the data XML file is a list of items, for example: <items>  <item>    apple  </item>  <item>    orange  </item>  <item>    water melon  </item>...</items>
I want to be able to tell the XSLT to only process specific items (say "apple" and "orange"). I've created a java.util.ArrayList and passed that to the transformer using setParameter( "theList", theList ).  In the XSLT, when I use <xsl:value-of select="$theList" />, I'll get in the output  [apple, orange].  Fair enough. However, what I really want (I think) is to take the array and iterate over it, calling a template for each item.  Is this possible? From what I've managed to deduce from a lot of searching/reading is that it's possible even to pass in a Java object and somehow get XSLT to access that Java object.  I'm not sure if that is overkill for what I want to do, but I cannot even achieve processing a list of items one by one.

Thanks in advance, Bernard. 		 	   		  

RE: Processing selected nodes...

Posted by Tom Morrison <to...@hillcountrysoftware.com>.
While this is the wrong list, I don't see anything in your request that
cannot be done using relatively simple XSLT.

 

I would invite you to post your question on the XML Forum at Tek-Tips, where
I have answered XSLT questions for years.  That way, the answer might
(might!) help someone else.  Registration is free, and it is absolutely the
most spam-free environment you can imagine.

http://www.tek-tips.com/threadminder.cfm?pid=426

 

Tom Morrison

Hill Country Software

 

From: Bernard Giannetti [mailto:thebernmeister@hotmail.com] 
Sent: Sunday, September 29, 2013 1:23 AM
To: fop-users@xmlgraphics.apache.org
Subject: Processing selected nodes...

 

Hi,

 

I'm using FOP, embedded in a desktop application, to create PDFs from a
single data XML file using an XSLT file.

 

Say the data XML file is a list of items, for example:

 

<items>

  <item>

    apple

  </item>

  <item>

    orange

  </item>

  <item>

    water melon

  </item>

...

</items>

I want to be able to tell the XSLT to only process specific items (say
"apple" and "orange").

 

I've created a java.util.ArrayList and passed that to the transformer using
setParameter( "theList", theList ).  In the XSLT, when I use <xsl:value-of
select="$theList" />, I'll get in the output  [apple, orange].  Fair enough.

 

However, what I really want (I think) is to take the array and iterate over
it, calling a template for each item.  Is this possible?

 

>From what I've managed to deduce from a lot of searching/reading is that
it's possible even to pass in a Java object and somehow get XSLT to access
that Java object.  I'm not sure if that is overkill for what I want to do,
but I cannot even achieve processing a list of items one by one.



Thanks in advance,

 

Bernard.


Re: Processing selected nodes...

Posted by Frank Hirsch <fr...@mac.com>.
Ups - sorry: "contains" instead of "substring" of course :/

Am 29.09.2013 um 17:47 schrieb Frank Hirsch <fr...@mac.com>:

> Right, not the right list…
> But maybe a quick and simple solution: <xsl:for-each select="//items/item[substr($theList,text()]"><xsl:for-each>?
> 
> Am 29.09.2013 um 17:20 schrieb Glenn Adams <gl...@skynav.com>:
> 
>> This question relates to XSLT, not XSL-FO or FOP, so this isn't really the right ML to post this.
>> 
>> 
>> On Sun, Sep 29, 2013 at 12:23 AM, Bernard Giannetti <th...@hotmail.com> wrote:
>> Hi,
>> 
>> I'm using FOP, embedded in a desktop application, to create PDFs from a single data XML file using an XSLT file.
>> 
>> Say the data XML file is a list of items, for example:
>> 
>> <items>
>>   <item>
>>     apple
>>   </item>
>>   <item>
>>     orange
>>   </item>
>>   <item>
>>     water melon
>>   </item>
>> ...
>> </items>
>> 
>> I want to be able to tell the XSLT to only process specific items (say "apple" and "orange").
>> 
>> I've created a java.util.ArrayList and passed that to the transformer using setParameter( "theList", theList ).  In the XSLT, when I use <xsl:value-of select="$theList" />, I'll get in the output  [apple, orange].  Fair enough.
>> 
>> However, what I really want (I think) is to take the array and iterate over it, calling a template for each item.  Is this possible?
>> 
>> From what I've managed to deduce from a lot of searching/reading is that it's possible even to pass in a Java object and somehow get XSLT to access that Java object.  I'm not sure if that is overkill for what I want to do, but I cannot even achieve processing a list of items one by one.
>> 
>> 
>> Thanks in advance,
>> 
>> Bernard.
>> 
> 


Re: Processing selected nodes...

Posted by Frank Hirsch <fr...@mac.com>.
Right, not the right list…
But maybe a quick and simple solution: <xsl:for-each select="//items/item[substr($theList,text()]"><xsl:for-each>?

Am 29.09.2013 um 17:20 schrieb Glenn Adams <gl...@skynav.com>:

> This question relates to XSLT, not XSL-FO or FOP, so this isn't really the right ML to post this.
> 
> 
> On Sun, Sep 29, 2013 at 12:23 AM, Bernard Giannetti <th...@hotmail.com> wrote:
> Hi,
> 
> I'm using FOP, embedded in a desktop application, to create PDFs from a single data XML file using an XSLT file.
> 
> Say the data XML file is a list of items, for example:
> 
> <items>
>   <item>
>     apple
>   </item>
>   <item>
>     orange
>   </item>
>   <item>
>     water melon
>   </item>
> ...
> </items>
> 
> I want to be able to tell the XSLT to only process specific items (say "apple" and "orange").
> 
> I've created a java.util.ArrayList and passed that to the transformer using setParameter( "theList", theList ).  In the XSLT, when I use <xsl:value-of select="$theList" />, I'll get in the output  [apple, orange].  Fair enough.
> 
> However, what I really want (I think) is to take the array and iterate over it, calling a template for each item.  Is this possible?
> 
> From what I've managed to deduce from a lot of searching/reading is that it's possible even to pass in a Java object and somehow get XSLT to access that Java object.  I'm not sure if that is overkill for what I want to do, but I cannot even achieve processing a list of items one by one.
> 
> 
> Thanks in advance,
> 
> Bernard.
> 


Re: Processing selected nodes...

Posted by Glenn Adams <gl...@skynav.com>.
This question relates to XSLT, not XSL-FO or FOP, so this isn't really the
right ML to post this.


On Sun, Sep 29, 2013 at 12:23 AM, Bernard Giannetti <
thebernmeister@hotmail.com> wrote:

> Hi,
>
> I'm using FOP, embedded in a desktop application, to create PDFs from a
> single data XML file using an XSLT file.
>
> Say the data XML file is a list of items, for example:
>
> <items>
>   <item>
>     apple
>   </item>
>   <item>
>     orange
>   </item>
>   <item>
>     water melon
>   </item>
> ...
> </items>
>
> I want to be able to tell the XSLT to only process specific items (say
> "apple" and "orange").
>
> I've created a java.util.ArrayList and passed that to the transformer
> using setParameter( "theList", theList ).  In the XSLT, when I
> use <xsl:value-of select="$theList" />, I'll get in the output  [apple,
> orange].  Fair enough.
>
> However, what I really want (I think) is to take the array and iterate
> over it, calling a template for each item.  Is this possible?
>
> From what I've managed to deduce from a lot of searching/reading is that
> it's possible even to pass in a Java object and somehow get XSLT to access
> that Java object.  I'm not sure if that is overkill for what I want to do,
> but I cannot even achieve processing a list of items one by one.
>
>
> Thanks in advance,
>
> Bernard.
>