Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Johannes 5 posts 25 karma points
    Mar 15, 2010 @ 13:44
    Johannes
    0

    Implementing the search

    Hi,

    I just started out with Umbraco, and wanted to implement your search.
    I keep getting an error in the xslt though(Error parsing XSLT file: \xslt\Search.xslt), on the line <xsl:variable name="results" select="ss4u.library:SearchToXml($phrase, 0, 'RecipeSearch')" />

    My search is defined in SimpleSearch4Umbraco.config as follows:

    <?xml version="1.0"?>
    <SimpleSearch4Umbraco xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SearchDefinition name="RecipeSearch" iterationType="IterateAll" isDefault="true">
    <DocumentType alias="Detail page" category="Recipe" includeChildNodes="true" testNodeName="true">
    <Property alias="Text" comparisonType="String" comparison="Contains" />
    <Property alias="Title" comparisonType="String" comparison="Contains" />
    <Property alias="Ingredients" comparisonType="String" comparison="Contains" />
    </DocumentType>
    </SearchDefinition>
    </SimpleSearch4Umbraco>

    The way I understood it was that the name of this search will be 'RecipeSearch', the documenttypes to search through are 'Detail page', and the fields on those detail pages are 'Text', 'Title' and 'Ingredients'. 
    I don't completely understand what the category is for, but as I understood it from the documentation it's for CSS.

    My site is built up as follows:
    Doctype Homepage
    Doctype Search
    Doctype Site section
    Doctype Detail page

    So the homepage has multiple site sections and a site section has multiple detail pages. There is 1 search page, which should show the results. 

    The xslt is pretty much the same as what was in the package, although I changed the sentence mentioned. 

    Is there anything I'm forgetting? Or do you see what I'm doing wrong? 

    Kind regards,
    Johannes Zijlstra

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Mar 15, 2010 @ 16:10
    Thomas Höhler
    0

    Hi Johannes,

    I am in stress today, will come back later this evening to you.

    Cheers, Thomas

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Mar 15, 2010 @ 16:40
    Thomas Höhler
    0

    BTW: last week I noticed that there is one point missing in the documentation: You have to add the xslSearch to the config/xsltExtensions.config:

    <ext assembly="/bin/SS4U.Library" type="SS4U.Library.Searcher" alias="ss4u" />

    And then you get automatically in a new xslt the new header like this:

    <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:ss4u="urn:ss4u"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ss4u ">

    Notice the two ss4u-entries in the stylesheet attributes header

    So I have to use update the documentation for this.

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Mar 15, 2010 @ 16:44
    Thomas Höhler
    0

    So please check the settings, also if the variables are set properly and it would be nice to see the complete xslt code...

    Cheer, Thomas

  • Johannes 5 posts 25 karma points
    Mar 15, 2010 @ 16:51
    Johannes
    0

    Hello Thomas,

    Thanks for your reply.

    The complete XSLT is as follows:
    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]> <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:ss4u.library="urn:ss4u.library" xmlns:ss4u="urn:ss4u" exclude-result-prefixes="msxml umbraco.library ss4u.library ss4u"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:variable name="recSearch" select="umbraco.library:RequestQueryString('q')"/> <xsl:if test="$recSearch!= ''"> <xsl:variable name="results" select="ss4u.library:SearchToXml($recSearch, 0, 'RecipeSearch')" /> <h2>Results</h2> <p>Your search for <strong>'<xsl:value-of select="$recSearch" />'</strong> returned <strong><xsl:value-of select="count($results/SearchResult)" /></strong> items</p> <ul> <xsl:for-each select="$results/SearchResult"> <xsl:sort select="@createDate" order="descending"/> <li><a href="{@linkUrl}"><xsl:value-of select="@text" /></a></li> </xsl:for-each> </ul> </xsl:if>

    I have added the xslsearch to the xsltExtensions.config as well. 

    Regards,
    Johannes

  • Johannes 5 posts 25 karma points
    Mar 15, 2010 @ 16:53
    Johannes
    0

    Also, if I remove everything except the request for the querystring and just paste the value of the querystring that is correct.  

    The error occurs on the call to SearchToXml. 

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Mar 15, 2010 @ 17:35
    Thomas Höhler
    0

    Now you have doubled the ss4u entries in the header. try this:

    <?xml version="1.0" 
    encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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:ss4u="urn:ss4u"
    exclude-result-prefixes="msxml umbraco.library ss4u">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:variable name="recSearch"
    select="umbraco.library:RequestQueryString('q')"/>
    <xsl:if test="$recSearch!= ''">
    <xsl:variable name="results" select="ss4u:SearchToXml($recSearch, 0, 'RecipeSearch')" />
    <h2>Results</h2>
    <p>Your search for <strong>'<xsl:value-of select="$recSearch" />'</strong> returned <strong><xsl:value-of select="count($results/SearchResult)" /></strong> items</p>
    <ul>
    <xsl:for-each select="$results/SearchResult">
    <xsl:sort select="@createDate" order="descending"/>
    <li><a href="{@linkUrl}"><xsl:value-of select="@text" /></a></li>
    </xsl:for-each>
    </ul>
    </xsl:if>

    hth, Thomas

  • Johannes 5 posts 25 karma points
    Mar 16, 2010 @ 08:10
    Johannes
    0

    Hello Thomas,

    Sorry for the delay, couldn't get back to you before now.

    With the change you suggested it works! Thanks!

    Cheers!

  • c 7 posts 27 karma points
    May 31, 2010 @ 12:37
    c
    0

    Hi Thomas,

    Does this search allow for searching for the search text on media items such as PDF files and MS office files? 

    thanks.

Please Sign in or register to post replies

Write your reply to:

Draft