[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] grabbing chunks of preceding-siblings between tables


Subject: Re: [xsl] grabbing chunks of preceding-siblings between tables
From: Tony Graham <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Oct 2007 17:33:10 +0100

On Thu, Oct 04 2007 16:40:18 +0100, spencertickner@xxxxxxxxx wrote:
> Thanks in advance for the help. I'm doing some pre-processing of a XML
> Dump of tables. I'm trying to associate header information in the
> table to the table itself. I'm having difficulty figuring out how to
> do this.. Anyway, examples always seem to say it better (XSLT 2.0 is
> fine):

XSLT 2.0 makes it much easier:

------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.0">

  <xsl:output method="xml"/>

  <xsl:template match="root">
    <xsl:copy>
      <xsl:for-each-group
        select="*"
        group-ending-with="table">
        <table>
          <xsl:apply-templates select="current-group()"/>
        </table>
      </xsl:for-each-group>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="table">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="*">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
------------------------------------------------------------

You don't show any attributes, so I didn't add anything to handle them.

Regards,


Tony Graham.
======================================================================
Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx   http://www.menteithconsulting.com

Menteith Consulting Ltd             Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
----------------------------------------------------------------------
Menteith Consulting -- Understanding how markup works
======================================================================


Current Thread
Keywords