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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--