[Newbie] for-each in template, or?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Larson

    [Newbie] for-each in template, or?

    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

    #2
    Re: [Newbie] for-each in template, or?

    John Larson wrote:
    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

    Comment

    Working...