Solved

Variable not defined error in xsl

Posted on 2004-08-20
6
269 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

11 Experts available now in Live!

Get 1:1 Help Now