Subject: Re: [xsl] Help with multiple key grouping... From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 19 Nov 2007 17:28:38 -0500 |
I am really new to XSL and have run into a problem I can't get a handle on. I am developing a document tracking system that will help out with letting employees know what documents are out for review, and when those reviews are due. I am also throwing in a list of all documents in the library. My current XML file looks like this:
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="gatorDocLibXsl_t3.xsl"?> <DocLib> <document> ...
So far I have figured out how to group my output by category. I also need to group the documents within the category by title so that I can sort them by version number. Below is my current stylesheet for grouping by category.
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> ...
Could someone please help me out with grouping both on category and title? I have looked through the archive postings most of the day and I still cannot figure out how this works. I am terribly confused and cannot find a lot of information on this on the web.
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Define keys for processing --> <xsl:key name="documentsByCategory" match="document" use="category"/>
<!-- Main processing --> <xsl:template match="DocLib"> <!-- Display all documents that are under review in a table--> <table border="1"> <caption>Documents for Review</caption> <tr> <th>Document Title</th> <th>Version</th> <th>Due Date</th> <th>Adjudication Date</th> <th>Comment Template</th> </tr>
<xsl:sort select="substring(docReview/dueDate,7,4)"/> <!-- Sort Day --> <xsl:sort select="substring(docReview/dueDate,1,2)"/> <!-- Sort Day --> <xsl:sort select="substring(docReview/dueDate,4,2)"/> <!-- Sort Day -->
<xsl:if test="docReview/complete='0'"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="version"/></td> <td><xsl:value-of select="docReview/dueDate"/></td> <td><xsl:value-of select="adjudication/date"/></td> <td><xsl:value-of select="docReview/commentTemplateFile"/></td> </tr>
</xsl:if> </xsl:for-each> </table>
<br/> <!-- Display all documents in the library in table format. The documents will be grouped by category (IRS, SSS, SRS, etc), then grouped by document name, and then sorted by version number. -->
<!-- This loop selects the unique categories and loops through them iteratively making a table from each category --> <xsl:for-each select="document[count(. | key('documentsByCategory', category)[1]) = 1]"> <xsl:sort select="category"/> <br/> <table border ="1"> <caption><xsl:value-of select="category"/> Documents</caption> <tr> <th>Title</th> <th>Version</th> <th>Review Comments/Response File</th> </tr>
<!-- This loops through all of the documents in each category --> <xsl:variable name="docs" select="key('documentsByCategory',category)"/> <xsl:for-each select="$docs"> <xsl:sort select="title"/> <xsl:if test="generate-id(.)= generate-id($docs[title=current()/title][1])"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="version"/></td> <!-- <td><xsl:value-of select="docReview/reviewCommentsFile"/></td> --> </tr> </xsl:if> </xsl:for-each> </table>
</xsl:for-each> </xsl:template>
-- 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Help with multiple key groupi, Hix, Robert W CIV NS | Thread | Re: [xsl] Table of contents for all, vwiswell |
[xsl] Help with multiple key groupi, Hix, Robert W CIV NS | Date | Re: [xsl] Table of contents for all, vwiswell |
Month |