Solved

Variable not defined error in xsl

Posted on 2004-08-20
6
270 Views
Last Modified: 2008-02-26
depending upon the condition i want to give background  color to the table row;

when i print the values of
<xsl:value-of select ="$origin"/> and
<xsl:value-of select ="$houseOrigin"/>
both r same;so bgcolor should come as  ">#FFFFCC;


<xsl:choose>
<xsl:when  test = "$origin = $houseOrigin">
<xsl:param name="bgcolor1">#FFFFCC</xsl:param>
</xsl:when>
<xsl:when  test = "$houseBBStatus = 'C' or $houseBBStatus = 'F'">
<xsl:param name="bgcolor1">#99FF66</xsl:param>
</xsl:when>
<xsl:when  test = "$houseBBStatus = 'O' or $houseBBStatus = 'P'">
<xsl:param name="bgcolor1">#FFCCFF</xsl:param>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>


<table>
      <tr bgcolor="{$bgcolor1}" style="font-size:8pt;" >
      <td>
      data...........
      </td>
      </table>
      </xsl:for-each>

      but i am getting this error

       XSL-1031: (Error) Variable not defined: 'bgcolor1'.
0
Comment
Question by:chaitu chaitu
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:metalmickey
ID: 11850033
i think your variables should be within your for-each statement, athough its not clear from the xslt youve posted.

if you post an xml snippet and your xslt i'll take a closer look.

MM
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 11850075
this is my xsl


<xsl:for-each select ="ROWSET/ROW">

<xsl:choose>
<xsl:when  test = "$origin = $houseOrigin">
<xsl:param name="bgcolor1">#FFFFCC</xsl:param>
</xsl:when>
<xsl:when  test = "$houseBBStatus = 'C' or $houseBBStatus = 'F'">
<xsl:param name="bgcolor1">#99FF66</xsl:param>
</xsl:when>
<xsl:when  test = "$houseBBStatus = 'O' or $houseBBStatus = 'P'">
<xsl:param name="bgcolor1">#FFCCFF</xsl:param>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>

      <tr bgcolor=$bgcolor1" style="font-size:8pt;" >
             <td align="center">
      <input type="checkbox" id="houseCheck{position()}" name="houseCheck" value="{ST}">
      <xsl:attribute name="onClick">
      setHouseChecked(<xsl:value-of select="position()"/>,<xsl:value-of select="count(//@id)"/>)
      </xsl:attribute>
            </input>

 <input type="hidden" id="houseStatus{position()}" name="houseStatus" value='{ST}'/>
   <input type="hidden" id="hawbHistoryStatus{position()}" name="hawbHistoryStatus" value='{ST}'/>
      </td>
                  <td  width="95" >      <xsl:value-of select="ID"/>
      <input type="hidden" id="houseDocId{position()}" name="houseDocId" value="{ID}"/>
      </td>
      <td  align="center" width="50" >
      <xsl:value-of select="OT"/>
      <input type="hidden" name="houseOriginTerminal"  value="{OT}"/>
      </td>
      <td  align="center" width="84" ><xsl:value-of select="DT"/>
      <input type="hidden" name="houseOriginTerminal"  value="{DT}"/>
      </td>
      <td  align="center" width="89" ><xsl:value-of select="SNAME"/>
      <input type="hidden" name="houseShipperId"  value="{SHID}"/>
      <input type="hidden" name="houseShipperName" value='{SNAME}'/>
      </td>
      <td  align="center" width="80" ><xsl:value-of select="CGNAME"/>
      <input type="hidden" name="houseConsigneeId"  value="{CHID}"/>
      <input type="hidden" name="houseConsigneeName" value='{CGNAME}'/>
      </td >

       <td   align="center" ><xsl:value-of select="SL"/>
      <input type="hidden" name="houseServiceLevelId" value='{SL}'/>                        
      <input type="hidden" name="houseServiceType" value='{PM}'/>                
      </td>
      <td   align="center" ><xsl:value-of select="PCS"/>
      <input type="hidden" name="houseTotalPieces" value='{PCS}'/>                        
      </td>
      <td  align="center" ><xsl:value-of select="GW"/>
      <input type="hidden" name="houseGrossWeight" value='{GW}'/>                        
      </td>
      <td  align="center" ><xsl:value-of select="CW"/>
      <font color='Green' size='1'>&nbsp;</font>
      <input type="hidden" name="houseChargeableWeight" value='{CW}'/>
      <input type="hidden" name="houseUOW" value='{UOW}'/>
      <input type="hidden" name="houseHazardousFlag" value='{HZD}'/>
      </td>
      <td  align="center" ><xsl:value-of select="VL"/><font color='Green' size='1'>&nbsp;<xsl:value-of select="VLUM"/></font>
      <input type="hidden" name="houseUOV" value='{VLUM}'/>       
       <input type="hidden" name="houseVolume" value='{VL}'/>
      </td>
      <td  align="center" ><xsl:value-of select="VOLUMETRIC_WT"/>
      <input type="hidden" name="houseVolumetric" value='{VOLUMETRIC_WT}'/>
      <input type="hidden" name="housedimFactor" value='{DFTR}'/>
      </td>
      <td  align="center" >&nbsp;<xsl:value-of select="duedate"/>
       <input type="hidden" name="houseDueDate" value=''/>
       <input type="hidden" name="houseDueTime" value=''/>
      <input type="hidden" name="houseUOMFlag" value='No'/>       
      <input type="hidden" name="isDomestic" id="isDomestic{position()}" value='{LEG_TYPE}'/>       
      <input type="hidden" name="bbStatus" id="bbStatus{position()}" value='{BB_STATUS}'/>
      <input type="hidden" name="hawbNo" id="hawbNo{position()}" value='{SNO}'/>
      <input type="hidden" name="routePlanId" id="routePlanId{position()}"  value='{RTID}'/>
      <input type="hidden" name="houseRoutePlanId" id="houseRoutePlanId{position()}"  value='{RTID}'/>
      <input type="hidden" name="hawbSeqNo" id="hawbSeqNo{position()}"   value='{SNO}'/>
      <input type="hidden" name="shipmentStatus" id="shipmentStatus{position()}"  value='{SS}'/>
      <input type="hidden" name="isAttachable" id="isAttachable{position()}"  value='YES'/>
      <input type="hidden" name="housePrintFlag"  id="housePrintFlag{position()}"  value='{PF}'/>
      <input type='hidden' name="houseSystemFlag" id="houseSystemFlag{position()}" value="{SYS_FLAG}"/>
      <input type='hidden' name="hawbFlag"  id="hawbFlag{position()}"  value="{HOUSE_TYPE}"/>
       </td>
      </tr>
      
      </xsl:for-each>
0
 
LVL 6

Expert Comment

by:metalmickey
ID: 11850088
and the xml?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 6

Expert Comment

by:metalmickey
ID: 11850130
Try this, it removes the need for a variable or a parameter and puts the choose statement within the the tr itself to add an attribute based on your tests.


#####  xsl  ###############

<xsl:for-each select ="ROWSET/ROW">
     <tr>
     <xsl:choose>
      <xsl:when test="$origin = $houseOrigin">
      <xsl:attribute name="style">font-size:8pt;background-color:#FFFFCC;</xsl:attribute>
      </xsl:when>
            <xsl:whentest = "$houseBBStatus = 'C' or $houseBBStatus = 'F'">
      <xsl:attribute name="style">font-size:8pt;background-color:#99FF66;</xsl:attribute>
      </xsl:when>
                  <xsl:whentest = "$houseBBStatus = 'O' or $houseBBStatus = 'P'">
      <xsl:attribute name="style">font-size:8pt;background-color:#FFCCFF;</xsl:attribute>
      </xsl:when>
    </xsl:choose>
     
           <td align="center">
     <input type="checkbox" id="houseCheck{position()}" name="houseCheck" value="{ST}">
     <xsl:attribute name="onClick">
     setHouseChecked(<xsl:value-of select="position()"/>,<xsl:value-of select="count(//@id)"/>)
     </xsl:attribute>
          </input>

 <input type="hidden" id="houseStatus{position()}" name="houseStatus" value='{ST}'/>
   <input type="hidden" id="hawbHistoryStatus{position()}" name="hawbHistoryStatus" value='{ST}'/>
     </td>
               <td  width="95" >     <xsl:value-of select="ID"/>
     <input type="hidden" id="houseDocId{position()}" name="houseDocId" value="{ID}"/>
     </td>
     <td  align="center" width="50" >
     <xsl:value-of select="OT"/>
     <input type="hidden" name="houseOriginTerminal"  value="{OT}"/>
     </td>
     <td  align="center" width="84" ><xsl:value-of select="DT"/>
     <input type="hidden" name="houseOriginTerminal"  value="{DT}"/>
     </td>
     <td  align="center" width="89" ><xsl:value-of select="SNAME"/>
     <input type="hidden" name="houseShipperId"  value="{SHID}"/>
     <input type="hidden" name="houseShipperName" value='{SNAME}'/>
     </td>
     <td  align="center" width="80" ><xsl:value-of select="CGNAME"/>
     <input type="hidden" name="houseConsigneeId"  value="{CHID}"/>
     <input type="hidden" name="houseConsigneeName" value='{CGNAME}'/>
     </td >

      <td   align="center" ><xsl:value-of select="SL"/>
     <input type="hidden" name="houseServiceLevelId" value='{SL}'/>                    
     <input type="hidden" name="houseServiceType" value='{PM}'/>                
     </td>
     <td   align="center" ><xsl:value-of select="PCS"/>
     <input type="hidden" name="houseTotalPieces" value='{PCS}'/>                    
     </td>
     <td  align="center" ><xsl:value-of select="GW"/>
     <input type="hidden" name="houseGrossWeight" value='{GW}'/>                    
     </td>
     <td  align="center" ><xsl:value-of select="CW"/>
     <font color='Green' size='1'>&nbsp;</font>
     <input type="hidden" name="houseChargeableWeight" value='{CW}'/>
     <input type="hidden" name="houseUOW" value='{UOW}'/>
     <input type="hidden" name="houseHazardousFlag" value='{HZD}'/>
     </td>
     <td  align="center" ><xsl:value-of select="VL"/><font color='Green' size='1'>&nbsp;<xsl:value-of select="VLUM"/></font>
     <input type="hidden" name="houseUOV" value='{VLUM}'/>      
      <input type="hidden" name="houseVolume" value='{VL}'/>
     </td>
     <td  align="center" ><xsl:value-of select="VOLUMETRIC_WT"/>
     <input type="hidden" name="houseVolumetric" value='{VOLUMETRIC_WT}'/>
     <input type="hidden" name="housedimFactor" value='{DFTR}'/>
     </td>
     <td  align="center" >&nbsp;<xsl:value-of select="duedate"/>
      <input type="hidden" name="houseDueDate" value=''/>
      <input type="hidden" name="houseDueTime" value=''/>
     <input type="hidden" name="houseUOMFlag" value='No'/>      
     <input type="hidden" name="isDomestic" id="isDomestic{position()}" value='{LEG_TYPE}'/>      
     <input type="hidden" name="bbStatus" id="bbStatus{position()}" value='{BB_STATUS}'/>
     <input type="hidden" name="hawbNo" id="hawbNo{position()}" value='{SNO}'/>
     <input type="hidden" name="routePlanId" id="routePlanId{position()}"  value='{RTID}'/>
     <input type="hidden" name="houseRoutePlanId" id="houseRoutePlanId{position()}"  value='{RTID}'/>
     <input type="hidden" name="hawbSeqNo" id="hawbSeqNo{position()}"   value='{SNO}'/>
     <input type="hidden" name="shipmentStatus" id="shipmentStatus{position()}"  value='{SS}'/>
     <input type="hidden" name="isAttachable" id="isAttachable{position()}"  value='YES'/>
     <input type="hidden" name="housePrintFlag"  id="housePrintFlag{position()}"  value='{PF}'/>
     <input type='hidden' name="houseSystemFlag" id="houseSystemFlag{position()}" value="{SYS_FLAG}"/>
     <input type='hidden' name="hawbFlag"  id="hawbFlag{position()}"  value="{HOUSE_TYPE}"/>
      </td>
     </tr>
     
     </xsl:for-each>
 

##########  xsl ###############

Hope this helps

MM
0
 
LVL 6

Accepted Solution

by:
metalmickey earned 250 total points
ID: 11850179
Sorry just spotted a typo in the 2nd whentest ="  should be when test="

<xsl:for-each select ="ROWSET/ROW">
     <tr>
     <xsl:choose>
      <xsl:when test="$origin = $houseOrigin">
      <xsl:attribute name="style">font-size:8pt;background-color:#FFFFCC;</xsl:attribute>
      </xsl:when>
            <xsl:whentest = "$houseBBStatus = 'C' or $houseBBStatus = 'F'">
      <xsl:attribute name="style">font-size:8pt;background-color:#99FF66;</xsl:attribute>
      </xsl:when>
                  <xsl:whentest = "$houseBBStatus = 'O' or $houseBBStatus = 'P'">
      <xsl:attribute name="style">font-size:8pt;background-color:#FFCCFF;</xsl:attribute>
      </xsl:when>
    </xsl:choose>
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 11850207
excellent
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
modifying sharepoint search results 13 34
Importing QRDA file 2 47
How to parse <assert> tag in XSD1.1 using XSOM Parser? 4 60
Strange html entity encoding by tidy 14 77
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now