|
Subject: RE: [xsl] how to test for the element type of the current node From: "Michael Kay" <mhk@xxxxxxxxx> Date: Wed, 2 Jul 2003 10:54:33 +0100 |
The logic
<for-each select="X">
<choose>
<when name="A">
<when name="B">
is needed so often that XSLT provides a special construct for it: it's
called xsl:apply-templates. Use it!
Michael Kay
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Godmar Back
> Sent: 02 July 2003 08:51
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] how to test for the element type of the current node
>
>
>
> Hi,
>
> what expression do I use if I need to test the type of the
> current node in a for-each loop?
>
> Say I have a DTD that has
>
> <!ELEMENT A (B|C)*>
>
> and I want to write
>
> <xsl:template match="A">
> <xsl:for-each select="*">
> <xsl:choose>
> <xsl:when test="if this node is a B"> <--- this is
> what I can't figure out
> apply-templates for B
>
> ...
> <xsl:otherwise>
> do something else for C
> ...
>
>
> I tried ".=B" inside the test, which doesn't work, I tried just "B",
> I tried "boolean(B)", nothing works.
>
> Note that I believe that using <xsl:template match="B"> won't
> solve my problem because I need to do something specific that
> I only need to if the
> B element is nested inside the A element.
>
> This seems such an elementary thing to do (!?), but maybe I
> still don't understand XSL well enough to see an alternative.
>
> Thanks!
>
> - Godmar
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] how to test for the eleme, David Carlisle | Thread | Re: [xsl] how to test for the eleme, Godmar Back |
| Re: [xsl] Netscape7.1 bug or bad co, David Carlisle | Date | RE: [xsl] how to test for the eleme, Michael Kay |
| Month |