Using XSLT 1.0, how to check if a value exists in a variable or not?
I assign a value to a variable from my XML data, and then have to check if it comes out or not:
<xsl:variable name="DOC_TYPE">
<xsl:value-of select="name(./RootTag/*[1])"/>
</xsl:variable>
<xsl:if test="string($DOC_TYPE) = ''">
<xsl:variable name="DOC_TYPE">
<xsl:value-of select="name(./*[1])"/>
</xsl:variable>
</xsl:if>
The above does not work properly. I need if in my data exists <RootTag>then the variable must contain the child element below <RootTag>. If <RootTag>not, then DOC_TYPE should be the first tag in my XML data.
Thanks for your reply.
sridhar
source
share