[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: how to test for the element type of the current no

Subject: RE: 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
RE:  how to test for the element type of the current no
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.