This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Conditional attributes based on presence of a child element
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Conditional attributes based on presence of a child element
- From: Wolfgang Bogacz <wbogacz at Omicron dot com>
- Date: Thu, 15 Mar 2001 18:14:31 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
Given the following input:
<group id="groupid1">
<rectangle id="rectangle1"/>
</group>
<group id="groupid2">
<rectangle id="rectangle2"/>
<processdata id="processdata2">data</processdata>
</group>
And the following template:
<xsl:template match="group">
<xsl:copy>
<xsl:copy-of select="@id"/>
<xsl:choose>
<xsl:when test="processdata">
<xsl:attribute name="type">y</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="type">x</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
I would like my output to add the new 'type' attribute based on the
presence of the 'processdata' child element as in:
<group id="groupid1" type="x">...</group>
<group id="groupid2" type="y">...</group>
But I always get type="x". I've prepended the './' to 'processdata' in the
test,
checked case, etc. nothing seems to matter.
Can anyone tell me what's wrong?
Thanks.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list