xsl-list
[Top] [All Lists]

RE: Make Hirachy from flat file

2003-10-13 23:20:59
Hi,

So far I have only managed to get items grouped by the 
row/data[1] element,
but it is the "nested" gruoping by the row/data[2] element there is
bothering me.

Did you want something in the lines of

  <xsl:key name="maingroup" match="row" use="data[1]"/>
  <xsl:key name="prodgroup" match="row" use="concat(data[1], ' ',data[2])"/>
  <xsl:template match="test">
    <xsl:copy>
      <xsl:for-each select="row[generate-id() = generate-id(key('maingroup', 
data[1]))]">
        <xsl:variable name="main" select="data[1]"/>
        <maingroup name="{$main}">
          <xsl:for-each select="../row[generate-id() = 
generate-id(key('prodgroup', concat($main, ' ',data[2])))]">
            <prodgroup name="{data[2]}">
              <xsl:for-each select="key('prodgroup', concat($main, ' 
',data[2]))">
                <rows>
                  <itemno>
                    <xsl:value-of select="data[3]"/>
                  </itemno>
                  <description>
                    <xsl:value-of select="data[4]"/>
                  </description>
                </rows>
              </xsl:for-each>
            </prodgroup>
          </xsl:for-each>
        </maingroup>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>

Cheers,

Jarno - Smashing Pumpkins: Eye

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



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