Charles, thanks for your input on this as well. Since
the solution originally came from you, I should have
directed this question to you. Sorry for not following
the messages in order.
Can you explain the use of the above select statement?
Is 'union' a key word? And can you interchange it with
the symbol '|'?
Imrran
<xsl:key name="union" match="group/table/col" use="@month" />
'union' is simply a string. It is the value of the "name" attribute of the
<xsl:key> element. It could have been anything, and reflecting on you question,
I suppose I should have used some name that wouldn't suggest a key word.
<xsl:key> creates a kind of index.
As for this:
<xsl:for-each select="table/col[count(.|key('union', @month)[1])=
1]">
the select attribute tells the processor to take all the "col" elements which
are children of "table" elements, which, in turn, are child elements of the
context node (in this case, the context node is "group") and return the count
of the union (which is represented by the vertical bar, or pipe character) of
the context node (here the context is switched to "col") and the nodeset
returned by the key() function.
The key() uses the index created by <xsl:key> to return a nodeset. The function
takes two arguments, first is the value of the name attribute of the <xsl:key>
element you want to work with, the second is the value you are looking for.
Here the @month[1] is the value of the first occurrence of a month attribute
value. Thus this returns all of the months, but only one of each.
So the <xsl:for-each> will iterate twelve times in this case. Each time we pull
out the value of the month with <td><xsl:value-of select="@month" /></td>, and
that gives us the column heads of the table.
All of this is explained in greater detail, and given the context and the
author, with pains taking attention to accuracy, in Michael Kay's XSLT
Programmer's Reference, 2nd Ed. from Wrox Books ISBN 1-861005-06-7.
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list