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

xsl:if to separate child elements

Subject: xsl:if to separate child elements
From: pmitra <pmitra@xxxxxxxxxxxxxxxxx>
Date: Mon, 25 Sep 2000 18:35:05 -0700
xsl if child elements
Hello,
 I am somehow really stuck trying to separate out different child
elements using <xsl:if>. Please help with the following situation if
possible:

Here is an example of the type of xml I am working with - 1 help element
with multiple heltext and helpexample elements:

<category name="science">
<help>
<helptext>
This is a descriptive note
</helptext>
<helpexample>
This is an example
</helpexample>
<helptext>
This is another line of text
</helptext>
</help>
</category>

I would like to do a for-each to be able to print out all helptext and
helpexample elements in sequence, but I would like to give a different
style to helptext vs helpexample (<pre></pre>). There may be unequal
numbers of these elements.
I am trying:

<xsl:for-each select="help/helptext|help/helpexample">
<xsl:if test="helptext"/>
<pre>
<xsl:value-of select="."/>
</pre>

<xsl:if test="position() mod 2=0">
<pre>
<xsl:value-of select="."/>
</pre>
</xsl:if>
</xsl-if>
</xsl:for-each>

</xsl:if>
</xsl:for-each>


the position() mod 2 part works, but I dont have any guarantee that the
particular element will always be in the even position.
I would appreciate any help...

Thank You,
Sincerely,
Mila Mitra
pmitra@xxxxxxxxxxxxxxxxx


 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.