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

Re: Table of contents for all groups at the beginning

Subject: Re: Table of contents for all groups at the beginning of each group
From: <vwiswell@xxxxxxxxxxx>
Date: Mon, 19 Nov 2007 14:12:06 -0600 (CST)
Re:  Table of contents for all groups at the beginning
Sorry for not being specific enough. the output would be something like:

<h1>Company Name</h1>
<hr/>

link to Department 1 group | link to Department 2 group | link to Department 3 group

<p><a id="department1 name"></a></p>
<h2>Department 1</h2>
<p>Employee Information</p>
<p>Employee Information</p>
...
<hr/>

link to Department 1 group | link to Department 2 group | link to Department 3 group

<p><a id="department2 name"></a></p>
<h2>Department 2</h2>
<p>Employee Information</p>
<p>Employee Information</p>
...
<hr/>

link to Department 1 group | link to Department 2 group | link to Department 3 group

<p><a id="department3 name"></a></p>
<h2>Department 3</h2>
<p>Employee Information</p>
<p>Employee Information</p>
...
<hr/>

Thanks for responding and I hope this clarifies what I need to do.

On Mon, 19 Nov 2007 14:50:30 -0500
 "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
> 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:
>>
>><corporation>
>>      <company>
>>          <employee>
>>              <department>a</department>
>>           </employee>
>>          <employee>
>>              <department>a</department>
>>           </employee>
>>           <employee>
>>              <department>a</department>
>>           </employee>
>>        </company>
>>      <company>
>>          <employee>
>>              <department>a</department>
>>           </employee>
>>         <employee>
>>              <department>a</department>
>>           </employee>
>>         <employee>
>>              <department>b</department>
>>           </employee>
>>           <employee>
>>              <department>c</department>
>>           </employee>
>>        </company>
>></corporation>
>>
>>
>>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()">
>>    <xsl:sort select="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.
> 
>>    <br/>
>>    <p><a id="&lt;xsl:value-of
>>select='current-grouping-key()'/&gt;"></a></p>
> 
> 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:
> 
>    <a id="{current-grouping-key()}">
> 
>>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

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-2013 All Rights Reserved.