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

RE: if to separate child elements

Subject: RE: if to separate child elements
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 26 Sep 2000 10:46:40 +0100
RE: if to separate child elements
>  I am somehow really stuck trying to separate out different child
> elements using <xsl:if>. Please help with the following situation if
> possible:
> I am trying:
> 
> <xsl:for-each select="help/helptext|help/helpexample">
> <xsl:if test="helptext"/>

Firstly, the xsl:if should be closed with ">" not "/>": an xsl:if with no
content is meaningless, since it does nothing, whether or not the condition
is true.

Secondly, if you want to test whether the element you are processing is a
helptext element, use <xsl:if test="self::helptext">. The way you've written
the test, you are testing whether the current element has a helptext child.

Thirdly, the best way of doing this kind of processing is to use
<xsl:apply-templates> and template rules, rather than xsl:for-each and
xsl:if.

> <xsl:if test="position() mod 2=0">
> the position() mod 2 part works, but I dont have any 
> guarantee that the
> particular element will always be in the even position.

If the elements won't always be in the even position, then I fail to see why
you are testing to see if the element is in an even position, and I don't
understand what you mean by saying it "works". Presumably you mean that it
sometimes gives the right answer... 

Mike Kay 


 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.