[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Combining segments by matching attributes
Dot Porter wrote:
<group> <text xml:id="A15"> <seg n="220.2">...</seg> <seg n="220.3">...</seg> (etc.) </text> <text xml:id="B15"> <seg n="220.2">...</seg> <seg n="220.3">...</seg> (etc.) </text> </group> Here is an XSLT 2.0 solution: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:for-each-group select="group/text/seg" group-by="@n"> <app> <xsl:apply-templates select="current-group()"/> </app> </xsl:for-each-group> </xsl:template> <xsl:template match="seg"> <reg wit="#{../@xml:id}"> <xsl:copy-of select="."/> </reg> </xsl:template> </xsl:stylesheet> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
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
|