This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

xsl:if to separate 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@mail.arc.nasa.gov


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]