[xsl] XSLT test of xsl variable problem

Subject: [xsl] XSLT test of xsl variable problem
From: Ann Marie Rubin <Annmarie.Rubin@xxxxxxx>
Date: Wed, 03 Nov 2004 10:09:35 -0500
Hi David,

Thanks for you response.  I'm trying a new approach but having trouble
constructing a test for the value of an xsl variable.

The var definition:

<xsl:variable name="testvar" select="'deployment-version'"/>

The if that tests whether or not the value of testvar matches the string
"deployment-version":

<xsl:if test="deployment-version=$testvar">

The test doesn't pass so nothing is output in the result tree.

Is this the correct way to compare the value of a string to the value of
an xsl variable?

Thanks,

Ann Marie


Here is the Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output indent="yes" method="xml"/>
    <xsl:variable name="testvar" select="'deployment-version'"/>
    <xsl:template match="*|@*|text()|comment()">
        <xsl:copy>
            <xsl:apply-templates select="*|@*|text()|comment()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template name="copy-content-no-attrs">
        <xsl:apply-templates
select="processing-instruction()|comment()|*|text()"/>
    </xsl:template>
    <xsl:template match="orion-web-app[@deployment-version]">
    <xsl:if test="deployment-version=$testvar">
   
   
               <xsl:copy>
            <xsl:attribute
name="deployment-version">:[value]</xsl:attribute>
            <xsl:apply-templates
select="@*[not(name()='deployment-version')]"/>
            <xsl:call-template name="copy-content-no-attrs"/>
        </xsl:copy>
        </xsl:if>
        </xsl:template>
           
    <xsl:template match="orion-web-app[@temporary-directory]">
          <xsl:if test="temporary-directory=$testvar">
            <xsl:copy>
            <xsl:attribute
name="temporary-directory">:[value]</xsl:attribute>
            <xsl:apply-templates
select="@*[not(name()='temporary-directory')]"/>
            <xsl:call-template name="copy-content-no-attrs"/>
        </xsl:copy>
        </xsl:if>
    </xsl:template>
    <xsl:template match="orion-web-app[@internationalize-resources]">
              <xsl:if test="internationalize-resources">
            <xsl:copy>
            <xsl:attribute
name="internationalize-resources">:[value]</xsl:attribute>
            <xsl:apply-templates
select="@*[not(name()='internationalize-resources')]"/>
            <xsl:call-template name="copy-content-no-attrs"/>
        </xsl:copy>
  </xsl:if>
    </xsl:template>
    <xsl:template match="orion-web-app[@default-mime-type]">
         <xsl:if test="default-mime-type">
            <xsl:copy>
            <xsl:attribute name="default-mime-type">:[value]</xsl:attribute>
            <xsl:apply-templates
select="@*[not(name()='default-mime-type')]"/>
            <xsl:call-template name="copy-content-no-attrs"/>
        </xsl:copy>
   </xsl:if>
    </xsl:template>
        <xsl:template
match="web-app-class-loader[@search-local-classes-first]">
     <xsl:if test="search-local-classes-first">
        <xsl:copy>
            <xsl:attribute
name="search-local-classes-first">:[value]</xsl:attribute>
            <xsl:apply-templates
select="@*[not(name()='search-local-classes-first')]"/>
            <xsl:call-template name="copy-content-no-attrs"/>
            </xsl:copy>
  </xsl:if>
        </xsl:template> 
        <xsl:template
match="web-app-class-loader[@include-war-manifest-class-path]">
          <xsl:if test="include-war-manifest-class-path">
        <xsl:copy>
            <xsl:attribute
name="include-war-manifest-class-path">:[value]</xsl:attribute>
            <xsl:apply-templates
select="@*[not(name()='include-war-manifest-class-path')]"/>
            <xsl:call-template name="copy-content-no-attrs"/>
            </xsl:copy>
   </xsl:if>  
        </xsl:template>      
 
</xsl:stylesheet>

Current Thread