Brick Wall 0 Newbie Poster

Hi everyone,

Im building a website for a client but they requested it in umbraco and Ive got an xslt query that has been bugging me for days.

I have built a search form user control which has three drop downs and i want to build an xslt macro that brings back search results based on values that the user selects.

  • location
  • Type
  • Capacity

so far i have the following code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet 
    version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:msxml="urn:schemas-microsoft-com:xslt" 
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:Examine="urn:Examine" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.email="urn:ucomponents.email" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.search="urn:ucomponents.search" 
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Examine ucomponents.dates ucomponents.email ucomponents.members ucomponents.search ">

<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:param name="currentPage"/>

    <!--General variables-->
    <xsl:variable name="sectionNode" select="$currentPage/ancestor-or-self::*/Venues/Country/Region/County/CityTown/Venue"/>

    <!--Form field variables-->
    <xsl:variable name="strtype" select="umbraco.library:RequestForm('ctl00$ctl00$ctl00$ContentPlaceHolderDefault$SearchForm_3$ddlFunctionTypes')"/>
    <xsl:variable name="strlocation" select="umbraco.library:RequestForm('ctl00$ctl00$ctl00$ContentPlaceHolderDefault$SearchForm_3$ddlLocation')"/> 
    <xsl:variable name="strcapacity" select="umbraco.library:RequestForm('ctl00$ctl00$ctl00$ContentPlaceHolderDefault$SearchForm_3$ddlGuestCapacity')"/>
    <xsl:variable name="strkeywords" select="Exslt.ExsltStrings:uppercase(umbraco.library:RequestForm('ctl00$ctl00$ctl00$ContentPlaceHolderDefault$KeywordForm_3$txtKeywords'))" />      

    <!-- Collect nodes if Form variable was set -->
    <xsl:variable name="typeNodes" select="$sectionNode[contains(venueFunctionTypes, $strtype)][normalize-space($strtype)]" />
    <xsl:variable name="locationNodes" select="$sectionNode[contains(cityTown, $strlocation)][normalize-space($strlocation)]" />
    <xsl:variable name="capacityNodes" select="$sectionNode[contains(guestCapacity, $strcapacity)][normalize-space($strcapacity)]" />
    <xsl:variable name="keywordNodes" select="$sectionNode[contains(Exslt.ExsltStrings:uppercase(pageKeywords), $strkeywords)][normalize-space($strkeywords)]" />


<xsl:template match="/">

<!-- Iterate through the combined set of nodes -->
<xsl:for-each select="$typeNodes | $locationNodes | $capacityNodes | $keywordNodes">


   <xsl:sort select="venueName" order="ascending" />

    <div class="venue-list">
        <h2><xsl:value-of select="venueName"/></h2>
        <p><xsl:value-of select="venueShortDescription"/></p>      

    </div>


</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

The problem i have with this code is

if the user just selects liverpool as the location then i want every single venue located in liverpool to show in the results.

Next if the user selects liverpool as the location and wedding as the function type i want only the venues who are located in liverpool and host the function type wedding to show in the results. If the venue is located in liverpool but doesn't host weddings then i don't want it to show or if the venue does host weddings but is not located in liverpool then again i dont want it to show either.

Again if the user now selects all three values, liverpool as the location, weddings as the function type and upto 200 guests as the as the capacity all i want to display in the search results is venues who match all three conditions. so if a venue is located in liverpool and it does hold upto 200 guests but it doesnt hold the function type wedding then i dont want it to show in the results.

Now im not sure if im thinking about this logic right (probably due to my lack of knowledge in xslt) but what i was thinking that the following 7 possibilities need to be considered.

option 1

Action = user selects just the location Result = fetch back everything that only matches the location specified

option 2

Action = user selects location and function type Result = fetch back everything that only matches the location and function type specified

option 3

Action = user selects location and capacity Result = fetch back everything that only matches the location and capacity specified

option 4

Action = user selects location, function type and capacity Result = fetch back everything that only matches the location, function type and capacity specified

option 5

Action = user selects just the function type Result = fetch back everything that only matches the function type specified

option 6

Action = user selects function type and capacity Result = fetch back everything that only matches the function type and capacity specified

option 7

Action = user selects just the capacity Result = fetch back everything that only matches the capacity specified

if anyone can help here that would be fantastic.

Thnaks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.