xsl variable not passing values in




<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" encoding="UTF-8"/>
<xsl:param name="contextPath">CONTEXT_PATH/</xsl:param>
<xsl:include href="xhtml.xsl"/>
<xsl:variable name="site"><xsl:value-of select="/leftnavigation/tree/path/node[2]/@name"/></xsl:variable>

<xsl:template match="leftnavigation">
<xsl:element name="h1">
<xsl:attribute name="id">banner</xsl:attribute>

<xsl:apply-templates select="bannerleftimage" />
<xsl:apply-templates select="bannermiddleimage" />
<xsl:if test="$site='Families'">
<xsl:apply-templates select="bannerrightimage" />

<!-- Just to output the value for dev purposes -->
<xsl:text><xsl:value-of select="$site"/></xsl:text>
</xsl:if>

</xsl:element>
<xsl:element name="div">
<xsl:attribute name="id">left_col</xsl:attribute>
<xsl:apply-templates select="sectionlist" />
</xsl:element>
</xsl:template>

<!-- BELOW IS JUST THE TEMPLATES AND THEY WORK FINE -->

</xsl:stylesheet>


What I'm trying to achieve:

I'm trying to set a condition around a template(bannerrightimage) to not appear for a specific brand(in your case the String) called 'Families'. The @name usually returns three strings, Families, Children, Adults. And it works in my other xsl files.


The issue I'm having is that the variable $site is not passing in any values. but if I had something like:



<xsl:variable name="site"><xsl:text>ABC123</xsl:text>


$site does output ABC123. As I mentioned before, if I'm in home.xsl I would have my variable as:



home.xsl



<xsl:variable name="site"><xsl:value-of select="/home/tree/path/node[2]/@name"/>


and if it's country.xsl I would set my variable as:



<xsl:variable name="site"><xsl:value-of select="/country/tree/path/node[2]/@name"/>


home.xsl and country.xsl work perfectly fine but when I implement the same style for my leftnavigation.xsl $site is not returning any value. not even an empty space...


No comments:

Post a Comment