xsl-list
[Top] [All Lists]

how to test for the element type of the current node

2003-07-02 00:51:20

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