Subject: Re: [xsl] Merging adjacent nodes of same type From: Matt Sims <mattsims@xxxxxxxxxxxxx> Date: Fri, 23 Sep 2005 13:19:51 +0100 |
David,This is a fairly standard grpuping question (google your way to jeni's site)
I've just tried it, but it doesn't appear to be working. Here is what I am using (modified slightly for my schema):
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aston="http://www.aston.tv/schemas/Aston/Aston7">
<xsl:template match="node()"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates select="node()[1]"/> </xsl:copy> <xsl:apply-templates select="following-sibling::node()[1]"/> </xsl:template>
<xsl:template match="aston:offset[not(node())]"> <xsl:param name="a" select="/.."/> <xsl:choose> <xsl:when test="following-sibling::node()[self::* or normalize-space(.)][1]/self::aston:offset[not(node())]"> <xsl:apply-templates select="following-sibling::aston:offset[1]"> <xsl:with-param name="a" select="$a|@*"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <offset x="{sum($a[name()='x']|@x)}" y="{sum($a[name()='y']|@y)}" z="{sum($a[name()='z']|@z)}"/> <xsl:apply-templates select="following-sibling::node()[1]"/> </xsl:otherwise> </xsl:choose> </xsl:template>
<text xmlns=\"http://www.aston.tv/schemas/Aston/Aston7\"> <offset x=\"0.1\" y=\"0\" z=\"0\" /> <offset x=\"0.1\" y=\"0\" z=\"0\" /> Aston Broadcast Systems Ltd. </text>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Merging adjacent nodes of, David Carlisle | Thread | Re: [xsl] Merging adjacent nodes of, David Carlisle |
Re: [xsl] Strict sequential identit, Dimitre Novatchev | Date | Re: [xsl] XSLT recursion problem, Ragulf Pickaxe |
Month |