![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - help wanted [Thread Next] Re: help wantedTo: NULL Date: 12/3/2006 2:10:00 AM
Maybe I am confused with what the exact issue is, but why not just use the
following?
dan
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/"><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:stylesheet>
<djcamo@i...> wrote in message
news:1164086635.757822.62480@m......
> 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:param name="rest" select="restaurants/restaurant"/>
> <xsl:param name="name" select="$rest/name"/>
> <xsl:param name="cuisine" select="$rest/cuisine"/>
> <xsl:param 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>qaz@w...</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>Thai@H...</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>qaz@w...</email>
> </restaurant>
> </restaurants>
>
> ---HTML Results (only Italian restaurants)---
> Name: Dave's Place
> Description: Homely little restaurant.
> Location: Kew
> Phone: 03 1111 2222
> Email: wsx@e...
>
> Name: La Porchetta
> Description: Homely little restaurant.
> Location: Kew
> Phone: 98530666
> Email: qaz@w...
>
> Name: Dave's Place
> Description: Homely little restaurant.
> Location: Kew
> Phone: 03 1111 2222
> Email: wsx@e...
>
> Name: La Porchetta
> Description: Homely little restaurant.
> Location: Kew
> Phone: 98530666
> Email: qaz@w...
>
> Name: Dave's Place
> Description: Homely little restaurant.
> Location: Kew
> Phone: 03 1111 2222
> Email: wsx@e...
>
> Name: La Porchetta
> Description: Homely little restaurant.
> Location: Kew
> Phone: 98530666
> Email: qaz@w...
>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
