Hello,
I have spent the better part of a week trying to figure out how to
dynamically filter data based upon text retrieved from a text box on a
web page. I am now at the stage where the filtering is working ok but I
get duplicate results. If I have 2 entries in the XML file I get the
results 2 time, if I have 3 entries i get the results 3 times (as
shown)etc. Can anyone tell me where I am going wrong. I have listed the
xsl file the xml data and the resulting html below.
Thanks in advance,
Dave
---XSL---
<xsl
aram name="rest" select="restaurants/restaurant"/>
<xsl
aram name="name" select="$rest/name"/>
<xsl
aram name="cuisine" select="$rest/cuisine"/>
<xsl
aram name="area" select="$rest/area"/>
<xsl:variable name="tableData">
<xsl:apply-templates select="$rest[area=$area and cuisine=$cuisine]"
mode="tableData" />
</xsl:variable>
<xsl:template match="restaurants/restaurant">
<xsl:apply-templates select="msxsl:node-set($tableData)/restaurant">
</xsl:apply-templates>
</xsl:template>
<xsl:template match="restaurant">
<span class="">
<b>Name: </b>
<xsl:value-of select="name" />
<br />
<b>Description: </b>
<xsl:value-of select="description" />
<br />
<b>Location: </b>
<xsl:value-of select="suburb" />
<br />
<b>Phone: </b>
<xsl:value-of select="phone" />
<br />
<b>Email: </b>
<a HREF="mailto:{email}">
<xsl:value-of select="email" />
</a>
<br />
<br />
</span>
</xsl:template>
<xsl:template match="restaurant" mode="tableData">
<xsl:copy>
<xsl:copy-of select="name"/>
<xsl:copy-of select="description"/>
<xsl:copy-of select="suburb"/>
<xsl:copy-of select="phone"/>
<xsl:copy-of select="email"/>
</xsl:copy>
</xsl:template>
---XML---
<restaurants>
<restaurant>
<name>Dave's Place</name>
<cuisine>Italian</cuisine>
<area>South</area>
<description>Homely little restaurant.</description>
<address>29 Walpole St</address>
<suburb>Kew</suburb>
<phone>03 1111 2222</phone>
<email>q...@wsx.com</email>
</restaurant>
<restaurant>
<name>Thai Harder</name>
<cuisine>Asian</cuisine>
<area>East</area>
<description>Homely little restaurant.</description>
<address>400 High St</address>
<suburb>Carlton</suburb>
<phone>03 9629 4566</phone>
<email>T...@Harder.com</email>
</restaurant>
<restaurant>
<name>La Porchetta</name>
<cuisine>Italian</cuisine>
<area>East</area>
<description>Homely little restaurant.</description>
<address>Walpole St</address>
<suburb>Kew</suburb>
<phone>98530666</phone>
<email>q...@wsx.com</email>
</restaurant>
</restaurants>
---HTML Results (only Italian restaurants)---
Name: Dave's Place
Description: Homely little restaurant.
Location: Kew
Phone: 03 1111 2222
Email: w...@edc.on.net
Name: La Porchetta
Description: Homely little restaurant.
Location: Kew
Phone: 98530666
Email: q...@wsx.com
Name: Dave's Place
Description: Homely little restaurant.
Location: Kew
Phone: 03 1111 2222
Email: w...@edc.on.net
Name: La Porchetta
Description: Homely little restaurant.
Location: Kew
Phone: 98530666
Email: q...@wsx.com
Name: Dave's Place
Description: Homely little restaurant.
Location: Kew
Phone: 03 1111 2222
Email: w...@edc.on.net
Name: La Porchetta
Description: Homely little restaurant.
Location: Kew
Phone: 98530666
Email: q...@wsx.com
I have spent the better part of a week trying to figure out how to
dynamically filter data based upon text retrieved from a text box on a
web page. I am now at the stage where the filtering is working ok but I
get duplicate results. If I have 2 entries in the XML file I get the
results 2 time, if I have 3 entries i get the results 3 times (as
shown)etc. Can anyone tell me where I am going wrong. I have listed the
xsl file the xml data and the resulting html below.
Thanks in advance,
Dave
---XSL---
<xsl
<xsl
<xsl
<xsl
<xsl:variable name="tableData">
<xsl:apply-templates select="$rest[area=$area and cuisine=$cuisine]"
mode="tableData" />
</xsl:variable>
<xsl:template match="restaurants/restaurant">
<xsl:apply-templates select="msxsl:node-set($tableData)/restaurant">
</xsl:apply-templates>
</xsl:template>
<xsl:template match="restaurant">
<span class="">
<b>Name: </b>
<xsl:value-of select="name" />
<br />
<b>Description: </b>
<xsl:value-of select="description" />
<br />
<b>Location: </b>
<xsl:value-of select="suburb" />
<br />
<b>Phone: </b>
<xsl:value-of select="phone" />
<br />
<b>Email: </b>
<a HREF="mailto:{email}">
<xsl:value-of select="email" />
</a>
<br />
<br />
</span>
</xsl:template>
<xsl:template match="restaurant" mode="tableData">
<xsl:copy>
<xsl:copy-of select="name"/>
<xsl:copy-of select="description"/>
<xsl:copy-of select="suburb"/>
<xsl:copy-of select="phone"/>
<xsl:copy-of select="email"/>
</xsl:copy>
</xsl:template>
---XML---
<restaurants>
<restaurant>
<name>Dave's Place</name>
<cuisine>Italian</cuisine>
<area>South</area>
<description>Homely little restaurant.</description>
<address>29 Walpole St</address>
<suburb>Kew</suburb>
<phone>03 1111 2222</phone>
<email>q...@wsx.com</email>
</restaurant>
<restaurant>
<name>Thai Harder</name>
<cuisine>Asian</cuisine>
<area>East</area>
<description>Homely little restaurant.</description>
<address>400 High St</address>
<suburb>Carlton</suburb>
<phone>03 9629 4566</phone>
<email>T...@Harder.com</email>
</restaurant>
<restaurant>
<name>La Porchetta</name>
<cuisine>Italian</cuisine>
<area>East</area>
<description>Homely little restaurant.</description>
<address>Walpole St</address>
<suburb>Kew</suburb>
<phone>98530666</phone>
<email>q...@wsx.com</email>
</restaurant>
</restaurants>
---HTML Results (only Italian restaurants)---
Name: Dave's Place
Description: Homely little restaurant.
Location: Kew
Phone: 03 1111 2222
Email: w...@edc.on.net
Name: La Porchetta
Description: Homely little restaurant.
Location: Kew
Phone: 98530666
Email: q...@wsx.com
Name: Dave's Place
Description: Homely little restaurant.
Location: Kew
Phone: 03 1111 2222
Email: w...@edc.on.net
Name: La Porchetta
Description: Homely little restaurant.
Location: Kew
Phone: 98530666
Email: q...@wsx.com
Name: Dave's Place
Description: Homely little restaurant.
Location: Kew
Phone: 03 1111 2222
Email: w...@edc.on.net
Name: La Porchetta
Description: Homely little restaurant.
Location: Kew
Phone: 98530666
Email: q...@wsx.com