[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Comparing Variables

Subject: RE: Comparing Variables
From: "Fernandes, John" <jfernandes@xxxxxxxxxx>
Date: Fri, 2 May 2003 09:08:20 -0400
xsl comparing variables
Rob just wanted to thank you for your reply and making me understand exactly
the error in the way I was understanding how the for-each works. This fixed
my problem. Once again thanks for the prompt reply.

John M. Fernandes

-----Original Message-----
From: me@xxxxxxxxxxxx [mailto:me@xxxxxxxxxxxx]
Sent: Thursday, May 01, 2003 3:08 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Comparing Variables


> Hi I am still new to this technology so bare with my
> problem. 
  
> I have a default value from a xml document for an
> employee as <employee>John
> Doe</employee>.
> In the XSL stylesheet I have a node set creating a
drop
> down list as
> described below
>  
> <select name="employee">             
>    <xsl:for-each select="$v_employee/name">
>         <option value="{.}"><xsl:value-of
> select="."/></option>
>        </xsl:for-each>     
>   </select>
>  
> My problem is this. I want to be able to compare as
> each list item is being
> created the value of the current item to the default
> value in employee, so
> that I may make that value on the list the Selected
> Item. I have tried the
> attempt below. However it seems that the value of the
> default value
> (employee) is always null.

Just so you know (you say you are new) - when using a
value-of and the thing you are trying to access doesn't
exists, it will return null as opposed to an error.

> ***<xsl:value-of select="employee"/> --- Value is John
> Doe ***********
at this point you could set
<xsl:variable name="sKeeper" select="employee" />
  
> <select name="employee">             
>    <xsl:for-each select="$v_employer/employer/option">
> 
> ***<xsl:value-of select="employee"/> --- Value is
empty
When you use the for-each you are moved into that part
of the tree. Meaning everything is relative to the point
$v_employer/employer/option. Is there an employee
element like $v_employer/employer/option/employee? if
not that is why it is null.

>  *********** 
if you use that variable comment above you could do
something like

<xsl:if test="string($sKeeper) = string(.)">
etc etc

>     <xsl:if test="employee= '{.}">
>      <option value="{.}"
> selected="selected"><xsl:value-of
> select="./description"/></option>
>     </xsl:if>    
>     <xsl:if test="not(employee= '{.}')">
>      <option value="{.}" "><xsl:value-of
> select="./description"/></option>
>     </xsl:if>        
>    </xsl:for-each>     
> </select>
>  
> I guess my question is can this be done or how can I
> bring a value from the
> main template in to be compared to the item on the
list
> as it is iterating
> through it.

I think you were just missing the fact that your
context moves.

Cheers,
Rob

    _/  _/_/    _/_/_/
   _/_/   _/ _/     _/
  _/               _/
 _/             _/
_/          _/_/_/_/
http://treebeard.sourceforge.net
http://ashpool.sourceforge.net

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Get to know us
http://www.thestar.com - Canada's largest daily newspaper online
http://www.toronto.com - All you need to know about T.O.
http://www.workopolis.com - Canada's biggest job site
http://www.torontostartv.com - Webcasting & Production
http://www.newinhomes.com - Ontario's Largest New Home & Condo Website
http://www.waymoresports.com - Canada's most comprehensive sports site
http://www.tmgtv.ca - Torstar Media Group Television

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Comparing Variables
    • Fernandes, John - Thu, 1 May 2003 13:45:16 -0400 (EDT)
      • <Possible follow-ups>
      • me - Thu, 1 May 2003 15:08:30 -0400 (EDT)
      • Fernandes, John - Fri, 2 May 2003 09:05:27 -0400 (EDT) <=
      • me - Fri, 2 May 2003 12:29:25 -0400 (EDT)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.