[XSL-LIST Mailing List Archive Home]
Re: [xsl] Table of contents for all groups at the beginning of each group
Subject: Re: [xsl] Table of contents for all groups at the beginning of each group|
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Nov 2007 14:50:30 -0500
At 2007-11-19 12:50 -0600, vwiswell@xxxxxxxxxxx wrote:
I've looked at a lot of examples but I still can't seem to figure out
how to do this. I am using XSLT 2.0. I am transforming XML to XHTML.
There are some fundamental problems in your stylesheet, plus your
question is not quite clear.
The XML is something like this:
I need to group employees within a company (selected with a param) by
department. No problem. What I also need to do is include a table of
contents at the beginning of each department grouping linking to each
of the other department groups. If there is only one department in the
company, I do not display a table of contents.
I'm lost as to which groupings you need and which you do not. Could
you please show an example of what you want output from the data
above, rather than showing us the stylesheet. That shows us what
doesn't work, not what you want.
<xsl:for-each-group select="//company" group-by="department/text()">
It is dangerous to use "/text()" in the above because of mixed
content. It is sufficient to say "department" because the text value
of an element is the concatenation of the descendant text nodes.
Your escaping of angle brackets in an attribute achieves
nothing. There is no such thing as element markup in an attribute
string. Use an attribute value template to do "value-of" in an attribute:
I think my problem is that I don't thoroughly understand how the XML
doc is processed so that I can get the group names at the beginning of
the the for-each-group.
What do you mean by a "group name"? If you mean the current grouping
key, then perhaps the above is all you need.
Remember also that you always get a group even if the count of
members of the group is one. If you don't want to do something if
there is only one member of the group, then you'll have to check the
count of the current group to determine that.
I hope this helps.
. . . . . . . . . . Ken
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds: publicly-available developer resources and training
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal