Connecting Tech Pros Worldwide Forums | Help | Site Map

[Newbie] for-each in template, or?

John Larson
Guest
 
Posts: n/a
#1: Sep 29 '08
Hi all,


I am trying to construct a simple table from XML files using XSLT. I would
like to put an ID from the document in column 1, and the content of some
elements that maybe repeated in column 2. Can this be done in a template
using a for-each, or should I use a sort of variable, or?

Desired output:

7817471 author1

7817471 author2

7817471 author3

7817472 author1

7817472 author2



the ID of each document would be in /inspec/article/contg/accn

and the repeated elements in e.g., /inspec/article/bibliog/aug/pname

Thanks for any help!

- John



Martin Honnen
Guest
 
Posts: n/a
#2: Sep 29 '08

re: [Newbie] for-each in template, or?


John Larson wrote:
Quote:
I am trying to construct a simple table from XML files using XSLT. I would
like to put an ID from the document in column 1, and the content of some
elements that maybe repeated in column 2. Can this be done in a template
using a for-each, or should I use a sort of variable, or?
>
Desired output:
>
7817471 author1
>
7817471 author2
>
7817471 author3
>
7817472 author1
>
7817472 author2
>
>
>
the ID of each document would be in /inspec/article/contg/accn
>
and the repeated elements in e.g., /inspec/article/bibliog/aug/pname
Can you post the XML you want to process? Based on the above I would
guess you might want
<xsl:for-each select="/inspec/article/bibliog/aug/pname">
<xsl:value-of select="concat(../../../contg/accn, ' ', .,
' ')"/>
</xsl:for-each>


--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread