[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Wrap changing element sequence into container: wit
> <!-- how to match g, h and i as well within the same > "for-each-group"? --> Two ways. I used a grouping key of exists(self::b|self::c) so it only has two states to group or not to group so like that you can only group one thing at a time, but that's OK as you can have more than one pass. <xsl:template match="flatsequence"> <hierarchy> <xsl:variable name="p1"> <xsl:for-each-group select="*" group-adjacent="exists(self::b|self::c)"> ... </xsl:variable> <xsl:for-each-group select="$p1/*" group-adjacent="exists(self::h|self::h|self::i)"> ... </xsl:for-each-group> </hierarchy> </xsl:template> Or you do it in one pass with a grouping key that has three states (and an xsl:choose with three branches. <xsl:template match="flatsequence"> <hierarchy> <xsl:for-each-group select="*" group-adjacent="if (exists(self::b|self::c)) then 1 if (exists(self::h|self::i|self::i)) then 2 else 0"> <xsl:choose> <xsl:when test="current-grouping-key()=1"> <group1><xsl:copy-of select="current-group()"/>... <xsl:when test="current-grouping-key()=2"> <group2><xsl:copy-of select="current-group()"/>... <xsl:otherwise> <xsl:copy-of select="current-group()"/>.. David
|
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
|