• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PLEASE HELP ME!!Creating drop down list using XSL

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a simple requirement but solution looks not very easy.
I need to create a dropdown list with value as selected for the xml file I have.
I have a simple xml output like this:
<?xml version="1.0" ?>
<ROWSET>
<ROW num="1">
<PRODUCTNAME>LG Golden Eye 29 inch CTV</PRODUCTNAME>
</ROW>
<ROW num="2">
<PRODUCTNAME>Murphy 21 COLOR TV</PRODUCTNAME>
</ROW>
</ROWSET>
I want to create a drop down list for the productname using xsl.
My xsl looks like this:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body bgcolor="#ffffff">
<table>
<tr>
<td>
<font color="#CC0000" size="+1">
<b> List of Products</b>
</font>
</td>
<FORM>
<td>
<SELECT NAME="P_PRODID">
<xsl:for-each select="/rowset/row">
<OPTION VALUE="{@productname}">
<xsl:value-of select="@productname"/>
</OPTION>
</xsl:for-each>
</SELECT>
</td>
</FORM>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I cannot see the value see the values in the drop down list. Please help me.
-raj
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, XML/XSLT are case sensitive, so if your XML document has element names in uppercase letters, you should use them in your XSLT also. Next, "@" symbol is used to retrieve attribute values, and you need element values Your for-each loop should be:
<xsl:for-each select="/ROWSET/ROW">
<OPTION VALUE="{PRODUCTNAME}">
<xsl:value-of select="PRODUCTNAME"/>
</OPTION>
</xsl:for-each>
 
raj agastya
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much. It really worked like a charm!
-raj
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic