[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: RE: loop elements based on attribute
Kjellaug Johansen wrote:
Now, I've got another problem. I want a list of Pkt-elements to be wrapped inside a List-element. Assuming you use XSLT 2.0 you can use xsl:for-each-group group-adjacent as follows: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="/test"> <xsl:copy> <xsl:for-each-group select="*" group-adjacent="boolean(self::Pkt)"> <xsl:choose> <xsl:when test="current-grouping-key()"> <List> <xsl:copy-of select="current-group()"/> </List> </xsl:when> <xsl:otherwise> <xsl:copy-of select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:copy> </xsl:template> </xsl:stylesheet> -- Martin Honnen http://JavaScript.FAQTs.com/
|
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
|