• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing if the parameter passed is empty..Help pls!

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I hav defined a variable and passing as a parameter to a template. It shd check if the param value is not empty and then use it.
How to check if the param is empty is not? This is how I Used...

<xsl:template match="root">
...
<xsl:variable name="var1">
<xsl:if test="TagA != '' ">
<tagx>123</tagx>
</xsl:if>
<xsl:variable>
...
<xsl:if test="TagY != '' ">
<xsl:call-template name="tempA">
<xsl:with-param name="var1" select="$var1"/>
</xsl:call-template>
</xsl:if>

...
</xsl:template>

<xsl:template name="tempA">
<xsl aram name="var1"/>

<xsl:if test="$var1">
<abc><xsl:value-of select="$var1"/><abc>
</xsl:if>
</xsl:template>
........

but the <abc> tag is always generated either with empty value or with the param value.

Is it OK with the code?

Pls help!!

thanks
Sunitha
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The condition you are using to check the param value is wrong. Here is the modified code....(check the code in bold)

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Additionally, you could also use the length() function on the var string variable to make a judgement.

- m
reply
    Bookmark Topic Watch Topic
  • New Topic