|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Conditional attributes based on presence of a child el
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








