Blog Stats
  • Posts - 42
  • Articles - 0
  • Comments - 98
  • Trackbacks - 34

 

Check for nodename in XSLT

Its always necessary sometimes in XSLT processing that we check for things like whether a node exists to do certain operations. Checking for nodenames is the clue. This is how you do it.

<xsl:variable name="varname"> 
  <xsl:value-of select="ParentNode/*[name()='childnodename to check for']"/>         
<xsl:variable>
<xsl:if test="$varname=''"> Processing here...
<xsl:if>

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: Check for nodename in XSLT

Gravatar Thank you! 5/17/2005 9:51 PM | Michiel

# re: Check for nodename in XSLT

Gravatar Exactly what I was looking for & without trawling through the w3c reference - thanks! 3/1/2006 6:08 AM | Mhunt

# re: Check for nodename in XSLT

Gravatar Hi, thanks for this tip, its a usable idea. How about <xsl:value-of select ="name(.)"/>? 7/28/2011 1:37 AM | Kir

# re: Check for nodename in XSLT

Gravatar Oh sorry you are exactly using <xsl:value-of select ="name(.)"/>, but with parent (captcha 'UPSZ' ^^) 7/28/2011 1:43 AM | Kir

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

 

 

Copyright © Vinayak