Re: [xsl] Grouping of Tags

Subject: Re: [xsl] Grouping of Tags
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Fri, 20 Jun 2003 21:22:29 +0200
Marc Baumgartner wrote:
In my XML I have two types of tags. My result should be a table where I want for every block of the first tag a new row which contains all the following second tags.
...

The key is to formulate the condition which should apply to the
<second> elements: following the actual <first>, and the first
preceding <first> of this <second> should be the actual <first>.
In XPath:
 <xsl:template match="first">
   <tr>
     <td><xsl:copy-of select="."/></td>
     <td>
       <xsl:copy-of select=following-sibling::second[
        generate-id(previous-sibling::first)
        = generate-id(current())]"/>
    </td>
   </tr>
  </xsl:template>

Beware: untested. May also be less efficient than other approaches,
try alternative formulations of the condition.

J.Pietschmann


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



Current Thread