[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

Subject: Conditional attributes based on presence of a child element
From: Wolfgang Bogacz <wbogacz@xxxxxxxxxxx>
Date: Thu, 15 Mar 2001 18:14:31 -0500
el conditional
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.