%META:TOPICINFO{author="PatrickDiamond" date="1099670876" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="XMLQueryPlugin"}%
---+ Recipe showing how to extract the values from a Table Column, sort them and produce a unique list
%TOC%

---++Sample Table 

| *Title* | *Author* |
| Early Israel and the Surrounding Nations | Sayce, Archibald Henry |
| Early Kings of Norway | Carlyle, Thomas |
| Early Letters of George Wm. Curtis | Cooke, George Willis |
| Early Letters of George Wm. Curtis | Curtis, George William |
| The Early Life of Mark Rutherford (W. Hale White) | Rutherford, Mark |
| Early Plays Catiline, the Warrior's Barrow, Olaf Liljekrans | Ibsen, Henrik |
| Early Plays Catiline, the Warrior's Barrow, Olaf Liljekrans | Orbeck, Anders |
| The Early Poems of Alfred Lord Tennyson | Collins, John Churton |
| The Early Poems of Alfred Lord Tennyson | Tennyson, Alfred Lord |
| Early Short Fiction of Edith Wharton Audio Book | Wharton, Edith |
| The Parenticide Club | Bierce, Ambrose |
| The Parent's Assistant | Edgeworth, Maria |
| Paris as It Was and as It Is | Blagdon, Francis W. |
| The Parish Clerk (1907) | Ditchfield, P. H. (Peter Hampson) |
| Parish Papers | Macleod, Norman |
| The Parish Register | Crabbe, George |

---++ Ordered List

%XSLTSTART{id="%WEB%" benchmark="off" debug="off" }% 
 <xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:set="http://exslt.org/sets"
  extension-element-prefixes="set">

 <xsl:template match="/twiki">

 <ol>
 <xsl:for-each select="set:distinct(/twiki/web/topic/data/tables/table/row[position()>1]/field[1])">
	  <xsl:sort select="."/>
	  <li><xsl:value-of select="."/></li>
 </xsl:for-each>
 </ol>

  </xsl:template>
  </xsl:stylesheet>
%XSLTEND%

---++Annotated XSLT

<verbatim>
%XSLTSTART{id="%WEB%" benchmark="off" debug="off" }% 
 <xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:set="http://exslt.org/sets"
  extension-element-prefixes="set">

</verbatim>
 __The last two parameters in the xsl:stylesheet tag include set processing functions__
<verbatim>

 <xsl:template match="/twiki">

 <ol>
 <xsl:for-each select="set:distinct(/twiki/web/topic/data/tables/table/row[position()>1]/field[1])">

</verbatim>
 __Extract the first column from all rows but the first and procduce a distinct list of the items__
<verbatim>

	  <xsl:sort select="."/>

</verbatim>
 __sort this list of items__
<verbatim>

	  <li><xsl:value-of select="."/></li>
 </xsl:for-each>
 </ol>

  </xsl:template>
  </xsl:stylesheet>
%XSLTEND%
</verbatim>

