tags:

views:

449

answers:

3

s0SelectedSite is an attribute of a class or a column of a table.

<xsl:if test="string-length(@s0SelectedSite) &gt; '0'">
<tr>
  <td width="50%" bgcolor="#C0C0C0"><font size="2"><b>Selected Site:</b></font></td>
  <td><font size="2">&#160;<xsl:apply-templates select="DBE:Attribute   [@name='s0SelectedSite']"/></font></td>
</tr> 
</xsl:if>

In the above, the value of s0SelectedSite exists but still the lines are not getting printed.

For eg. It should display the following:-

Selected Site:             Singapore

Please let me know if something is wrong.

+1  A: 

I find this generally works for checking to see if a tag is populated

<xsl:if test="@s0SelectedSite !=''">

Could you provide a sample of the xml, as I use this all the time and am wondering if the xpath is the issue.

Wiretap
Hello Rob, welcome. Start the line with 4 spaces for code formatting, or select the code and click the code button (101010)
Kobi
I tried this but it did not work.I got the below error in tomcatERROR: 'null'FATAL ERROR: 'Could not compile stylesheet'
prashant rao
+1  A: 
  1. Try <xsl:if test="string-length(@s0SelectedSite) &gt; 0"> (and not '0').
  2. Try <xsl:if test="@s0SelectedSite"> , see if it's working for you.
Kobi
A: 

I tried this way now --> It worked for me :

<xsl:choose>
  <xsl:when test="string-length(DBE:Attribute[@name='s0SelectedSite']/node()) &gt; 0"> 
    <table>
...
    </table>
  </xsl:when>
  <xsl:otherwise>
    <table>
...
    </table>
  </xsl:otherwise>
</xsl:choose>
prashant rao
<xsl:when test="string-length(DBE:Attribute[@name='s0SelectedSite']/node()) > 0"> ..........worked
prashant rao
Hello Prashant Rao, welcome. Start the line with 4 spaces for code formatting, or select the code and click the code button (101010). Thanks.
Kobi
Thanks to all for your responses.
prashant rao