|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Merging adjacent nodes of same type
David,This is a fairly standard grpuping question (google your way to jeni's site) Thanks for your informative answer and suggested template. 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:output method="xml" indent="yes"/> <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></xsl:stylesheet> Here is the exact XML I am trying it on: <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> Can you spot any obvious mistakes I may have made? Regards, Matt.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








