Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Variable not defined error in xsl

Posted on 2004-08-20
6
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

704 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