Take a look at here, Jeni demystifies the the usage of keys.
cheers,
Jarkko
http://www.jenitennison.com/xslt/grouping/index.html
Lainaus Paul Tremblay <phthenry(_at_)earthlink(_dot_)net>:
< I would like to find just the first element of certain nodes. My XML
< document looks something like this:
<
< <doc>
<
< <para name = "Normal" left-indent = "18"> text</para>
<
< <para name = "Normal" left-indent = "18"> more text</para>
<
< <para name = "any possible name" left-indent = "5"> more text</para>
<
< <para name = "any possible name" left-indent = "5"> some more text</para>
<
< <border top-border = "1">
<
< <para name = "another name" left-indent = "3"> text</para>
<
< </border>
<
< <table>
< <row>
< <cell><para name = "still another name" left-indent="2"> cell
< text</cell>
< </row>
< </table>
<
< </doc>
<
< I need my resulting document to look like this:
<
< <doc>
<
< <table-of-styles>
< <para-style name = "Normal" left-indent = "18"/>
< <para-style name = "any possible name" left-indent = "3">
< <para-style = "another name" left-indent = "3"/>
< <para-style name = "still another name" left-indent="2"/>
< </table-of-style>
<
< <!--rest of the document-->
<
< </doc>
<
< Notice that I have just one para-style elelement for each name--one for
< "Normal", one for "another name", and one for "still another name", and
< so on.
<
< I need to then create a text string for each of the para-style elements.
< I cannot duplicate the string.
<
< Notice also that the para element can occur in many different places.
<
< I know to start with something like this:
<
< <xsl:template match = "doc">
<
< <xsl:for-each select = "descendant::para">
< <!--here is where I don't know what to do-->
<
< </xsl:for-each>
<
< <xsl:apply-templates/>
< </xsl:template>
<
< I think I have to use a generate-id function in my xsl:for-each loop?
< But I've never done this before.
<
< Thanks
<
<
<
<
< --
<
< ************************
< *Paul Tremblay *
< *phthenry(_at_)earthlink(_dot_)net*
< ************************
<
< XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
<
<
***************************************************
* Jarkko Moilanen *
* Dokumentoinnin kehittäjä *
* Profound XML technology Expert *
* DokuMentori Oy *
* www.dokumentori.fi *
***************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list