xsl-list
[Top] [All Lists]

Re: Simple Xsl Problem

2003-11-09 17:38:27
Nischal wrote:
I trying to build a generic xsl transform which would
pick up all the unique Orders(Order1's, Order2's and
Order3's and so on...) and build a table like below.

It seems Muenchean grouping gives the most elegant and
generalizable solution.
Try
 <xsl:key name="orders-by-name" match="orders/*" use="name()"/>
 <xsl:template match="Orders">
  <xsl:for-each select="*[generate-id()=generate-id(key(
    'orders-by-name',name())[1])]">
    <p><xsl:value-of select="name()"/></p>
    <table>
      <tr>
        <xsl:for-each select="*">
          <td><xsl:value-of select="name()"/></td>
        </xsl:for-each>
      </tr>
      <xsl:for-each select="key('orders-by-name',name())">
        <tr>
          <xsl:for-each select="*">
            <td><xsl:value-of select="."/></td>
          </xsl:for-each>
        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>
Untested, beware of small problems, it's in the midst of the night.

J.Pietschmann


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



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