Solved

Variable not defined error in xsl

Posted on 2004-08-20
6
273 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

762 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