[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|