Re: [xsl] 'Variable' question from Newbie

Subject: Re: [xsl] 'Variable' question from Newbie
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Fri, 08 Nov 2002 22:42:36 +0100
Surla, Stacy wrote:
I have a collection of publications records in XML that store Discipline,
Title, Date, and other characteristics, including a flag indicating whether
the publication should show up on a Highlights page. I now want to output
the Highlights page, and I want the value of Discipline to be output only
once per group of records sharing that discipline. E.g.

That's a grouping problem. Look into the XSL FAQ for "grouping", or at http://www.jenitennison.com/xslt/grouping/index.html

Your groups are keyed by the Disciplines element. Think of
it as the following pseudo code:
  select first members of all groups
    output Discipline
    select all members of current group
      Output values of Title, Publisher, and Date

Some XSLT to get you started
  <xsl:key name="r-d" match="Record" use="Disciples"/>
  <xsl:template match="InstCorr">
    <xsl:for-each select="Record[
        generate-id()=generate-id(key('r-d',Disciples)]">
      <xsl:value-of select="Disciples"/>
      <xsl:for-each select="key('r-d',Disciples)">
        <xsl:value-of select="Title"/>
        ...
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>
(Beware: untested)

J.Pietschmann


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread