This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How best to duplicate nodes??
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] How best to duplicate nodes??
- From: "Hewko, Doug" <Doug dot Hewko at ccra-adrc dot gc dot ca>
- Date: Tue, 7 Aug 2001 15:39:18 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
Can someone please help steer me in the right direction? I have an XML file
where people can be in one or more list (example below). I would like the
output to be grouped according to the team the person is one. Problem is
that I may now know what teams someone is in and I do not want to copy the
node in the XML file to have a one-to-one relationship for person to group.
I got the grouping to work. I am also to duplicate every node. The way I am
looking at doing this is to count the number of <group> entries. If it is
more than one, then I will duplicate the <member> node. Somehow, I will need
to ignore the first instance. Any recommendations?
Ideally, I would like to use a for-each command to create a new XML file
where each instance of <group> exists. Unfortunately, I do not know how to
set this up in Cocoon2 to have my desired output displayed.
************************** desired output ********************
Team A
Joe Blow
Jane Dane
Team B
Joe Blow
Jane Dane
Jerry Berry
Team C
Jane Dane
************************ my XML file ************************
<teammembers>
<member contact="yes">
<group>Team A</group>
<group>Team B</group>
<name>
<given_name>Joe</given_name>
<last_name>Blow</last_name>
</name>
</member>
<member>
<group>Team A</group>
<group>Team B</group>
<group>Team C</group>
<name>
<given_name>Jane</given_name>
<last_name>Dane</last_name>
</name>
</member>
<member>
<group>Team B</group>
<name>
<given_name>Jerry</given_name>
<last_name>Berry</last_name>
</name>
</member>
**************(part of) my XSL file ****************************************
<xsl:template match="teammembers">
<xsl:copy-of select="member" />
<xsl:for-each select="member[count()"/>
..... from here I am grouping. Code removed for brevity.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list