how can I test current element type?

Subject: how can I test current element type?
From: Dave Carlson <dcarlson@xxxxxxxxxxxxxx>
Date: Tue, 25 Aug 1998 10:34:49 -0600
I'd like to test the *current* element type within an <xsl:if /> statement,
but this does not seem possible in the current XSL pattern syntax. In the
following extract, I tried the statement:
        <xsl:if test=".[Interface]">interface </xsl:if>
But, this is rejected by the XT processor.  I intend for this to say "is the
current element of type 'Instance'?"  Should this be accepted? Is there an
alternative?

  <xsl:template match="Package">
    <xsl:process select="ownedElement/Interface"/>
    <xsl:process select="ownedElement/Class"/>
  </xsl:template>

  <xsl:template match="Interface|Class">
    <DIV style="color: black; padding: 6px; font-size: 12pt; font-weight: bold">
      <xsl:process select="visibility"/><xsl:text> </xsl:text>
      <xsl:process select="isLeaf"/><xsl:text> </xsl:text>
      <xsl:process select="isAbstract"/><xsl:text> </xsl:text>
      <xsl:process select="ownerScope"/><xsl:text> </xsl:text>
      <xsl:if test=".[Interface]">interface </xsl:if>
      <xsl:if test=".[Class]">class </xsl:if>
      <xsl:process select="name"/><xsl:text> </xsl:text>
      <xsl:process select="generalization"/>
    </DIV>
    ... more stuff
  </xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread