Subject: RE: [xsl] Matching similar rows in a table From: <Jarno.Elovirta@xxxxxxxxx> Date: Thu, 15 Jul 2004 11:51:57 +0300 |
FAQ, > I want to transform the below source xml to the destination xml with > a XSLT script. I run into problems trying to generate the > <chapter></chapter> tags because there is no structural textual > "signal" in the source XML to match the start/end of a chapter. > > The source XML is the export from a DB in the form of a table. Each > page is in a row, only the first page has the chapter title, in the > other page that column contains no data. > > The XSLT script has to pick up the special first row, create the > chapter and name tags and insert the pages for the chapter until > another special first row is detected. > > Alternatively I could generate XML which has the chapter name in each > first column in the page row. Then the XSLT script will has to detect > a change in the content of the first column and start a new chapter. > > How can I do this in XSLT? A grouping problem, see <http://jenitennison.com/xslt/grouping>. <xsl:template match="*[row]"> <xsl:for-each select="row[col[1]/node()]"> <chapter> <name> <xsl:value-of select="col[1]"/> </name> <xsl:apply-templates select="."/> </chapter> </xsl:for-each> </xsl:template> <xsl:template match="row"> <page> <content> <xsl:value-of select="col[3]"/> </content> </page> <xsl:apply-templates select="following-sibling::row[1][not(col[1]/node())]"/> </xsl:template> Cheers, Jarno - Front Line Assembly: Plasticity
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Matching similar rows in a ta, Aadjan van der Helm | Thread | RE: [xsl] Matching similar rows in , Pieter Reint Siegers |
RE: [xsl] Getting Extra space while, Leena Sharma | Date | [xsl] position() in sequences in XS, ben . pickering |
Month |