tags:

views:

137

answers:

1

Hello.

What I am doing is reading in some xml and using xsl to output it in a table to make it more readable.

So some sample xml:

<example1>
  <sample name="aaa">
    <help1>Help</help1>
    <help2>Me</help2>
  </sample>
  <sample name="bbb">
    <noHelp1>No</noHelp1>
    <noHelp2>Help</noHelp2>
  </sample>
</example1>

So I have a for-each loop to go through each sample. so <xsl:for-each select="example1/sample"> and will use some value-of statements to print some of the values into a table.

Now what I wanted to do was use an if statement to say

if for-each sample, example1/sample/help1 = valid path, then do something

So I thought it would be something along the lines of...

...
<xsl:if test = "something">
  <xsl:for-each select="example1/sample">
    doWork
  </xsl:for-each>
</xsl:if>

The problem is I don't know how to test for this, ie. I don't know what the 'something' should be. I'm also not sure if I should use the if statement within the for-each statement instead.

Any help would be much appreciated.

+2  A: 
<xsl:for-each select="example1/sample">
  <xsl:if test="help1">
    <!-- now we know that this example1/sample has a help1 child -->
  </xsl:if>
</xsl:for-each>
AakashM
I have tried this and for some reason it doesn't work. Are there any alternatives?
If this does not work then your question and your actual problem are separate things.
Tomalak