This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Grouping repeating elements
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Grouping repeating elements
- From: tcn at melvaig dot co dot uk (Trevor Nash)
- Date: Thu, 12 Jul 2001 19:14:59 GMT
- Organization: Melvaig Software Engineering Limited
- References: <20010712100037.88349.qmail@web14902.mail.yahoo.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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"::FirstName[1]/>
><xsl:copy-of select="following-sibling"::Age[1]
>generate-id(prededing-sibling::Name[1])=generate-id(current())]/>
>
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">
<person>
<xsl:copy-of ... />
</person>
</xsl:variable>
<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.
Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email
Melvaig Software Engineering Limited
voice: +44 (0) 1445 771 271
email: tcn@melvaig.co.uk
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list