This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Conditional attributes based on presence of a child element


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]