Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Subject: Counting Path Occurrences

From: "Scott Coon" <scoon@------------->
To:
Date: 4/4/2007 2:12:00 AM
> On 4/1/07, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
> > On 3/30/07, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:
>
> >    <xsl:for-each-group
> >      select="//*/string-join(ancestor-or-self::*/name(), '/')"
> >      group-by=".">
> >          <xsl:sequence select="concat('&#xa;', ., ' - ',
count(current-group()))"/>
> >    </xsl:for-each-group>
>
>
> Nice solution.
>
> Except, if we change slightly the concat to following (please note a
> starting '/'):
> concat('&#xa;', '/', ., ' - ', count(current-group()))
>
>
> We'll get exactly what the OP wants.


So, just to make sure I understand this right, for each descendent node,
you use this string-join function to build the full path via the
ancestors:

 -- string-join(ancestor-or-self::*/name(), '/')

Since you're doing this in the select clause of the for-each-group, the
things to be grouped are already the desired paths, so you just group-by
".".  And for the same reason, you can use "." in the concat clause to
format the output.

I would also get the same result by separating things like this, right?

<xsl:for-each-group select="//*"
group-by="string-join(ancestor-or-self::*/name(), '/')">
[blah....]
</xsl:for-each-group>

Guys, this is terrific.  Thanks very much for the prompt replies.

Scott


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