Solved

Variable not defined error in xsl

Posted on 2004-08-20
6
271 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Merge 2 XML Files together 5 50
How can i generate these XML with SimpleXML() 5 75
Viewing XML as a table on a Mac 3 134
XSLT -  replace invalid xml characters 15 35
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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