xsl-list
[Top] [All Lists]

Re: 'Variable' question from Newbie

2002-11-08 14:42:36
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



<Prev in Thread] Current Thread [Next in Thread>