Re: Search example

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Search example

Marcus-2
Hi Ryan,
some time ago you send me a XPL for my search-request and now i have some questions, cause it doesn't work so far :-(
 
in my page-flow i entered the following line:
<page id="search01" path-info="/search/service/search_exist" view="search01.xpl"></page>
 
when sending my submission, the URL is:
 
the submission is:
<xforms:submission id="search01" ref="xxforms:instance('search01-instance')" method="get" action="/search/service/search_exist" replace="all" show="new" />
 
the code i copied from you is:
 
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xdb="http://orbeon.org/oxf/xml/xmldb"
xmlns:lw-p="http://www.puddzy.com/namespaces/lorna-web/products">
    <p:param name="instance" type="input"/>
    <p:param name="data" type="output"/>
 
<p:processor name="oxf:xslt-2.0">
    <p:input name="data" href="#instance"/>
    <p:input name="config">
<xdb:query xsl:version="2.0" collection="/db/kkbib">
xquery version "1.0";
declare namespace xmldb=http://exist-db.org/xquery/xmldb;
import module namespace t=http://exist-db.org/xquery/text;
declare namespace demo=http://www.mbeddow.com/demo;
declare option exist:serialize "highlight-matches=elements method=xhtml media-type=application/xhtml+xml";
 
<xsl:variable name="search-criteria">
    <xsl:choose>
        <xsl:when test="contains(/search-criteria,' ')">
        (
            <xsl:for-each select="tokenize(/search-criteria,' ')">
                '<xsl:value-of select="."/>'
                <xsl:if test="not(position() = last())">,</xsl:if>
            </xsl:for-each>
        )
        </xsl:when>
        <xsl:otherwise>
            '<xsl:value-of select="/search-criteria"/>'
        </xsl:otherwise>
    </xsl:choose>
</xsl:variable>
 
<result>
    <term>
        <xsl:value-of select="$search-criteria"/>
    </term>
{
let $hits := collection('/db/kkbib/forms')//form[text:match-any(.,<xsl:value-of select="$search-criteria"/>)]
for $hit in $hits
return
$hit
}</result>
 
</xdb:query>
</p:input>
<p:output name="data" id="search-query" debug="SQ"/>
</p:processor>
 
<!-- query exist for products -->
<p:processor name="oxf:xmldb-query">
    <p:input name="datasource" href="datasource.xml"/>
    <p:input name="query" href="#search-query"/>
    <p:output name="data" ref="data"/>
</p:processor>
</p:config>
 
But my result-page show an empty <term>-tag, so that the search-criteria = '' and for that, nothing is searched :-((
Can you help me with that a point me to the failure?
 
Thanks, Marcus
 
 
----- Original Message -----
Sent: Sunday, April 08, 2007 3:43 PM
Subject: Search example

Marcus,
    This example, takes a submitted instance (from the instance param) and passes this into an xslt processor, the instance is one element

<search-criteria>my search</search-criteria>

The XSLT creates a variable which splits the search criteria into seperate tokens to match on, the above would be ('my','search')

The xquery predicate uses the match-any function against a sequence of name and description fields, the function is match-any(sequence-to-search,criteria-sequence-string), then it returns the results. If you want to check what the xslt, a debug (SQ) is produced depending on you Log4J settings.

Finally the xquery is sent off to exist using xmldb-query, passing all the necessary params (check OF docs for more info on this)

HTH, if you need any more direction feel free to email me

Ryan
--

Ryan Puddephatt
Software Engineer
 
Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP
 
e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Search example

Ryan Puddephatt
Marcus,
    Parameters are not placed in the #instance by default, you would have to use the page-flow to add this, or you can use oxf:request processor to get the parameters.

HTH

Ryan

Ryan Puddephatt
Software Engineer
 
Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP
 
e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com

"Measuring programming progress by lines of code is like measuring aircraft building progress by weight." - Bill Gates
"If you lie to the compiler, it will get its revenge." - Henry Spencer
"It's hard enough to find an error in your code when you're looking for it; it's even harder when you've assumed your code is error-free." - Steve McConnell
"If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization." - Gerald Weinberg



Marcus wrote:
Hi Ryan,
some time ago you send me a XPL for my search-request and now i have some questions, cause it doesn't work so far :-(
 
in my page-flow i entered the following line:
<page id="search01" path-info="/search/service/search_exist" view="search01.xpl"></page>
 
when sending my submission, the URL is:
 
the submission is:
<xforms:submission id="search01" ref="xxforms:instance('search01-instance')" method="get" action="/search/service/search_exist" replace="all" show="new" />
 
the code i copied from you is:
 
    <p:param name="instance" type="input"/>
    <p:param name="data" type="output"/>
 
<p:processor name="oxf:xslt-2.0">
    <p:input name="data" href="#instance"/>
    <p:input name="config">
<xdb:query xsl:version="2.0" collection="/db/kkbib">
xquery version "1.0";
declare namespace xmldb=http://exist-db.org/xquery/xmldb;
import module namespace t=http://exist-db.org/xquery/text;
declare namespace demo=http://www.mbeddow.com/demo;
declare option exist:serialize "highlight-matches=elements method=xhtml media-type=application/xhtml+xml";
 
<xsl:variable name="search-criteria">
    <xsl:choose>
        <xsl:when test="contains(/search-criteria,' ')">
        (
            <xsl:for-each select="tokenize(/search-criteria,' ')">
                '<xsl:value-of select="."/>'
                <xsl:if test="not(position() = last())">,</xsl:if>
            </xsl:for-each>
        )
        </xsl:when>
        <xsl:otherwise>
            '<xsl:value-of select="/search-criteria"/>'
        </xsl:otherwise>
    </xsl:choose>
</xsl:variable>
 
<result>
    <term>
        <xsl:value-of select="$search-criteria"/>
    </term>
{
let $hits := collection('/db/kkbib/forms')//form[text:match-any(.,<xsl:value-of select="$search-criteria"/>)]
for $hit in $hits
return
$hit
}</result>
 
</xdb:query>
</p:input>
<p:output name="data" id="search-query" debug="SQ"/>
</p:processor>
 
<!-- query exist for products -->
<p:processor name="oxf:xmldb-query">
    <p:input name="datasource" href="datasource.xml"/>
    <p:input name="query" href="#search-query"/>
    <p:output name="data" ref="data"/>
</p:processor>
</p:config>
 
But my result-page show an empty <term>-tag, so that the search-criteria = '' and for that, nothing is searched :-((
Can you help me with that a point me to the failure?
 
Thanks, Marcus
 
 
----- Original Message -----
Sent: Sunday, April 08, 2007 3:43 PM
Subject: Search example

Marcus,
    This example, takes a submitted instance (from the instance param) and passes this into an xslt processor, the instance is one element

<search-criteria>my search</search-criteria>

The XSLT creates a variable which splits the search criteria into seperate tokens to match on, the above would be ('my','search')

The xquery predicate uses the match-any function against a sequence of name and description fields, the function is match-any(sequence-to-search,criteria-sequence-string), then it returns the results. If you want to check what the xslt, a debug (SQ) is produced depending on you Log4J settings.

Finally the xquery is sent off to exist using xmldb-query, passing all the necessary params (check OF docs for more info on this)

HTH, if you need any more direction feel free to email me

Ryan
--

Ryan Puddephatt
Software Engineer
 
Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP
 
e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws