This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: conditional copying of nodes?
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] conditional copying of nodes?
- From: "Hewko, Doug" <Doug dot Hewko at ccra-adrc dot gc dot ca>
- Date: Tue, 21 Aug 2001 14:50:31 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
I've got the copy working but how I can incorporate this into my sort? I am
trying to copy the existing <member> tree to <newmember> for the sorting.
Here's the XSL...
?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="simple-page2html.xsl" />
<xsl:key name="contacts-by-group" match="newmember" use="group" />
<xsl:template match="teammembers">
<xsl:apply-templates select="member"/>
<xsl:for-each select="newmember[count(. | key('contacts-by-group',
group)[1]) = 1]">
<xsl:sort select="group" />
....sorting code removed for brevity....
</xsl:template>
<xsl:template match="member">
<xsl:for-each select="group">
<newmember>
<xsl:copy-of select="."/>
<xsl:copy-of select="../name"/>
<xsl:copy-of select="../e_mail"/>
<xsl:copy-of select="../phone"/>
</newmember>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
-----Original Message-----
How can I do conditional copying of nodes? For example, I have the following
XML snippet, with an individual being in one or many groups. I am doing a
Muenchian method sort, which works. (Thanks Jeni!) The problem is that I am
unable to put someone more than one group unless I physically duplicate
their record. In the example below, I would copy my name, e-mail and phone
twice; once using the <group> of "Core Group" and once using "Steering
Committee".
XML:
<teammembers>
<member contact="yes">
<group>Core Team</group>
<group>Steering Committee</group>
<name>
<given_name>Doug</given_name>
<last_name>Hewko</last_name>
</name>
<e_mail>doug.hewko</e_mail>
<phone>
<number>555-1234</number>
</phone>
</member>
<member contact="yes">
<group>Core Team</group>
<name>
<given_name>John</given_name>
<last_name>Doe</last_name>
</name>
<e_mail></e_mail>
<phone>
<number>342-1234</number>
</phone>
</member>
</teammembers>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list