This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
xsl:if to separate child elements
- To: XSL-List at mulberrytech dot com
- Subject: xsl:if to separate child elements
- From: pmitra <pmitra at mail dot arc dot nasa dot gov>
- Date: Mon, 25 Sep 2000 18:35:05 -0700
- Organization: Computer Associates - SOFIA
- Reply-To: xsl-list at mulberrytech dot com
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@mail.arc.nasa.gov
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list