RE: [xsl] Generic Dropdown template

Subject: RE: [xsl] Generic Dropdown template
From: Rod Humphris - FLPTN <rod.humphris@xxxxxxxxxxxxxx>
Date: Mon, 24 Mar 2003 16:48:32 -0000
Hi Atul

This is my generic listbox template:
<xsl:template name="ListBox">
 <xsl:param name="ListNodes"/>
 <xsl:param name="ListName"/>
 <xsl:param name="currentVal"/>
 <select name="{$ListName}">
  <xsl:choose>
   <xsl:when test="$currentVal='All'">
    <option value='All'>&lt;All&gt;</option>
    <xsl:for-each select="$ListNodes">
     <xsl:sort/>
     <option><xsl:value-of select="normalize-space(.)"/></option>
    </xsl:for-each>
   </xsl:when>
   <xsl:otherwise>
    <option><xsl:value-of select="$currentVal"/></option>
    <option value='All'>&lt;All&gt;</option>
    <xsl:for-each select="$ListNodes[normalize-space(.)!='$currentVal']">
     <xsl:sort/>
     <option><xsl:value-of select="normalize-space(.)"/></option>
    </xsl:for-each>
   </xsl:otherwise>
  </xsl:choose>
 </select>
</xsl:template>

You would have to change it to write your options values etc and you
probably don't need normalize-whitespace(). Then throw it a node set
($ListNodes)

Cheers

Rod

-----Original Message-----
From: atulss@xxxxxxxxxx [mailto:atulss@xxxxxxxxxx]
Sent: 24 March 2003 15:58
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Generic Dropdown template


Hi,

As in my application, there are many dropdowns for which data may come from
XML,
(eg. to display date - day, month, year or grade of user etc.)
I would like to create new generic template for displaying dropdown on the
screen. 

but this doesn't work. Can anybody help me.
thanks in advance.

	<xsl:template name="GetDropDown">		
		<xsl:param name="xpath"/>		
		<xsl:param name="option"/>		
		<xsl:param name="id"/>		
		<xsl:param name="sel"/>		
		<xsl:for-each select="$xpath">			
			<option>				
				<xsl:attribute name="value">

					<xsl:value-of select="ID"/>

				</xsl:attribute>

				<xsl:if test="($id) = ($sel)">

					<xsl:attribute name="selected">
							true
					</xsl:attribute>

				</xsl:if>				
				<xsl:value-of
select="$option"></xsl:value-of>			
			</option>		
		</xsl:for-each>	
	</xsl:template>	

My XML look like, where User_info element stores id for the selected option.

<ROOT>
	<USER_INFO>
		<USER_NAME>Kevin Smith</USER_NAME>
		<GRADE>2</GRADE>
	</USER_INFO>
	
	<GRADE>
		<ROW num="1"> <M>Grade 1</M><ID>1</ID> </ROW>
		<ROW num="2"> <M>Grade 2</M><ID>2</ID> </ROW>
		<ROW num="3"> <M>Grade 3</M><ID>3</ID> </ROW>
		<ROW num="4"> <M>Grade 4</M><ID>4</ID> </ROW>
		<ROW num="5"> <M>Grade 5</M><ID>5</ID> </ROW>
	</GRADE>
</ROOT>	

regards,
Atul Samnerkar




MASTEK
Investing in relationships
In the US, we're called MAJESCO

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that
of Mastek Limited, unless specifically indicated to that effect. Mastek
Limited does not accept any responsibility or liability for it. This e-mail
and attachments (if any) transmitted with it are confidential and/or
privileged and solely for the use of the intended person or entity to which
it is addressed. Any review, re-transmission, dissemination or other use of
or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. This e-mail and
its attachments have been scanned for the presence of computer viruses. It
is the responsibility of the recipient to run the virus check on e-mails and
attachments before opening them. If you have received this e-mail in error,
kindly delete this e-mail from all computers.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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


________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________


________________________________________________________________
Any opinions expressed in this email are those of the individual and not necessarily the Company. Unless expressly stated to the contrary, this email is not intended to give rise to a new, or affect an existing, contractual or other legal relationship.This email and any files transmitted with it, including replies and forwarded copies which may contain alterations) subsequently transmitted from the Company, are confidential and solely for the use of the intended recipient. The unauthorised use, disclosure or copying of this email, or any other information contained or attached,is prohibited and could, in certain circumstances, be a criminal offence.

If you have received this email in error please notify the sender as soon as possible.

This footnote also confirms that this email message has been swept for the presence of computer viruses.

www.focusdiy.co.uk
_________________________________________________________________

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

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


Current Thread