Re: [xsl] Grouping repeating elements

Subject: Re: [xsl] Grouping repeating elements
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Thu, 12 Jul 2001 19:14:59 GMT
On Thu, 12 Jul 2001 03:00:37 -0700 (PDT), Till wrote:

>Hi Trevor
>thanks for the help.
>> So, add a further condition that the <name> node
>> before the one you
>> have found is the same node as the one matched in
>> your template: use
>> preceding-sibling and generate-id().
>I managed to create the result tree with:
><xsl:copy-of select=".">
><xsl:copy-of select="following-sibling"::Age[1]
Well done.

>Is it possible to apply further templates to the
>result-tree - or do I have to create a new
>xml-document with the result-tree first and then apply
>a second stylesheet to that new document?
In standard XSLT, thats your only option. But assuming you want to
process a person at a time, you can put the result inside an
xsl:variable.  Strictly speaking the only thing you can do with this
is copy it unchanged to the result tree, but most processors have a
function like node-set() which you can use like this:

  <xsl:variable name="tree">
               <xsl:copy-of ... />
  <xsl:apply-templates select="xx:node-set($tree)" />

The 'xx' depends on your processor - read the docs carefully to see
exaclty what needs to be done here.  Some even let you get away with
  <xsl:apply-templates select="$tree" />
because thats how they think its going to be in the next version of
the XSLT spec.

Hint: because you are going to process the same elements (e.g. age)
again, you may need to use modes.

Trevor Nash
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 XSL-List info and archive:

Current Thread