[xsl] Re: Getting output from a dropdown (Spry) menu?

Subject: [xsl] Re: Getting output from a dropdown (Spry) menu?
From: "Keith Hughes" <keithihughes@xxxxxxxxx>
Date: Thu, 22 Nov 2007 17:16:19 +0000
Hi again,
Just to update this, I could use a standard dropdown menu rather than
a Spry, as such:

- <body>
- <select name="list">
<option value="1">Programmer</option>
<option value="2">Not Programmer</option>
- </select>

- <table border="1">
- <tr>
<th>Name</th>
<th>Job</th>
<th>Salary</th>
</tr>
- <xsl:for-each select="company/department/employee">
- <xsl:if test="job = 'Programmer'">
- <tr>
- <td>
<xsl:value-of select="name" />
</td>
- <td>
<xsl:value-of select="job" />
</td>
- <td>
<xsl:value-of select="salary" />
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

In this case I'd want the filtering code to read something along the lines of:
- <xsl:if test="job = 'list'">

Can I use xsl:variable?

Thanks for any help on this....



On 22/11/2007, Keith Hughes <keithihughes@xxxxxxxxx> wrote:
> Hi all,
> I'm trying to search an XML document using drop down menus. I'm
> filtering using XSL, but I want to know how to use the output of a
> Spry dropdown menu to filter the rest of the XML. Here's some basic
> code:
>
> <?xml version="1.0" encoding="utf-8" ?>
> - <!-- DWXMLSource="company.xml"
> -->
> <!DOCTYPE xsl:stylesheet (View Source for full doctype...)>
> - <xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/Transform";>
> <xslutput method="html" encoding="utf-8" doctype-public="-//W3C//DTD
> XHTML 1.0 Transitional//EN"
> doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
> />
> - <xsl:template match="/">
> - <html xmlns="http://www.w3.org/1999/xhtml";
> xmlns:spry="http://ns.adobe.com/spry";>
> - <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Untitled Document</title>
> <script src="SpryAssets/xpath.js" type="text/javascript" />
> <script src="SpryAssets/SpryData.js" type="text/javascript" />
> - <script type="text/javascript">
> - <xsl:text disable-output-escaping="yes">
> - <![CDATA[ var ds1 = new Spry.Data.XMLDataSet("company.xml",
> "company/department/employee/job",{distinctOnLoad:true});
> ]]>
>
> </xsl:text>
> </script>
> </head>
> - <body>
> - <div spry:region="ds1">
> - <select name="select" spry:repeatchildren="ds1">
> <option value="{job}">{job}</option>
> </select>
> </div>
> <p> </p>
> - <table border="1">
> - <tr>
> <th>Name</th>
> <th>Job</th>
> <th>Salary</th>
> </tr>
> - <xsl:for-each select="company/department/employee">
> - <xsl:if test="job = 'Programmer'">
> - <tr>
> - <td>
> <xsl:value-of select="name" />
> </td>
> - <td>
> <xsl:value-of select="job" />
> </td>
> - <td>
> <xsl:value-of select="salary" />
> </td>
> </tr>
> </xsl:if>
> </xsl:for-each>
> </table>
> </body>
> </html>
> </xsl:template>
> </xsl:stylesheet>
>
> As you can see, I'm currently filtering using a xml:if function. The
> current filter will only give me the output of staff who are
> programmers (<xsl:if test="job = 'Programmer'">). What I want to do is
> use the output of the Spry drop down menu (ds1) to use as the filter,
> e.g. <xsl:if test="job = DS1">, but I don't know the correct way to do
> this.
>
> It may be easier t get rid of the Spry dropdown and use a xsl/html
> dropdown instead, but Spry seemed to be an easier way to go.
>
> I'm using Dreamweaver CS3 to produce this.
>
> If anyone could help it would be great. Hopefully it's pretty simple.
>
> Cheers.

Current Thread