Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] grouping, xslt 2.0

From: Abel Braaksma <abel.online@--------->
To:
Date: 4/4/2007 9:37:00 AM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent