[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: grouping, xslt 2.0

Subject: Re: grouping, xslt 2.0
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 04 Apr 2007 11:34:51 +0200
Re:  grouping
From John Jacks, posted against the digest:

In an XSLT pattern, current() refers to the node you are trying to match. So
the pattern

group-starting-with="*[name() = translate(name(current()),'1234','2345')]">

is wrong. Try assigning the result of the translate() to a variable first.


Thanks. (The hint in XSLT 2.0, 3Ed, p298 is wrong then).


Using <xsl:template match="*[starts-with(name(),'h')]">
<xsl:variable name="tag" select="translate(name(current()),'1234','2345')"/>
<xsl:message>
Match on <xsl:value-of select="name()"/>
Population is <xsl:value-of select="count(current-group())"/>
next is <xsl:value-of select="$tag"/>
</xsl:message>
<section level="{substring-after(name(),'h')}">
<head><xsl:apply-templates/></head>
<xsl:for-each-group select="current-group() except ."
group-starting-with="*[name() = $tag]">
<xsl:apply-templates select="current-group()"/>
</xsl:for-each-group>
</section>
</xsl:template>


Still doesn't hack it though.
It seems to handle the lower levels,
but not something like h3
h3
h2


I.e. 'rising' levels which should be legitimate in the input I'm using.

I'll try some stuff from XSLT 1.0


What exactly do you mean with 'rising'? What you mean by 'handling lower levels'?

Of course you can go back to XSLT 1.0 Muenchian grouping, you can do that with XSLT 2.0 as well, but surely, the grouping solution you are after must be way simpler with using the grouping construct.

What is the actual output you are getting as opposed to the actual output you are expecting?

Cheers,
-- Abel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.