xsl-list
[Top] [All Lists]

Re: Grouping of Tags

2003-06-20 12:22:29
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



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