[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|