xsl-list
[Top] [All Lists]

Re: [xsl] Choosing based on current node

2007-02-12 09:35:47
I think Abel has given some good remarks.

But I think, your code fragment needs to be modified as:

<xsl:for-each select="A|B|C">
 <xsl:choose>
    <xsl:when test="self::A">
      <xsl:call-template name="do-A"/>
    </xsl:when>
    <xsl:when test="self::B">
      <xsl:call-template name="do-B"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="do-C"/>
    </xsl:otherwise>
 </xsl:choose>
</xsl:for-each>

On 2/12/07, sthomas2(_at_)ups(_dot_)com <sthomas2(_at_)ups(_dot_)com> wrote:

I'm amazed at how patient this list is with newbie questions; I hope
this question doesn't try that patience too much. I'm processing a
document that has <A> or <B> or <C> elements in it. I need to preserve
their order in the output, but do something drastically different for
each. It seems like the following ought to work, but, instead, the
otherwise branch is always performed, regardless of whether the element
is A, B, or C. (The for-each is working fine, as it correctly skips over
any elements other than A, B, or C.)

<xsl:for-each select="A|B|C">
   <xsl:choose>
       <xsl:when test=".=A">
           <xsl:call-template name="do-A"/>
       </xsl:when>
       <xsl:when test=".=B">
           <xsl:call-template name="do-B"/>
       </xsl:when>
       <xsl:otherwise>
           <xsl:call-template name="do-C"/>
       </xsl:otherwise>
   </xsl:choose>
</xsl:for-each>

Thanks in advance,

Stephen


--
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--