[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

XQuery in Web Application

Wei, Alice J. ajwei at indiana.edu
Fri Mar 7 15:16:02 PST 2008


  XQuery in Web Application
Hi, XQueryers,

  I don't know if anyone has tried this.
  I intend on turning the code below into a web interface so I could search through my database collections. I used Saxon to debug my errors, and it apparently is giving me something like this in the following:

  F [Saxon9B XQuery] Cannot find a matching 1-argument function named {http://chausie.slis.indiana.edu:8080/exist/xquery/request}get-parameter()

 It appears that this is an XQuery issue, but I am not sure if something like get-parameter() or  session:set-attribute() is an XQuery supported function.
 If anyone has tried designing a web search using XQuery, I would love to hear about what are the possible solutions to my errors here.

Thanks in advance.

xquery version "1.0";
(: Searching through Collections :)

declare namespace request="http://chausie.slis.indiana.edu:8080/exist/xquery/request";
declare namespace session="http://chausie.slis.indiana.edu:8080/exist/xquery/session";
declare variable $data := fn:collection("xmldb:exist://db/cbml")//ad;

declare function local:input($search as xs:anyAtomicType)
as xs:string?
 {
    let $search := request:get-parameter($search")
      return
       ( session:set-attribute("search", 0)
       )
};

declare function local:search($search as xs:anyAtomicType
    ) as element()
{
let $sorted_result:=
for $doc in session:get-attribute(distinct-values($search))
order by $doc
return $doc
for $d at $count in $sorted_result
    return (
        session:set-attribute("search", $count),
        if ($count lt 1) then
            <p>Sorry, there are no results retrieved back. Please check for your input. </p>
        else if ($count gt 200) then
            <p>Sorry, too many results returned. Please refine your search to have them displayed.</p>
        else
       let $journal := $search[. =$d][1]/ancestor::cbml//seriesStmt/title[@level='journal']
let $volume := $search[. =$d][1]/ancestor::cbml//seriesStmt/idno[@type='volume']
let $issue := $search[. =$d][1]/ancestor::cbml//seriesStmt/idno[@type='issue']
let $head2 := $search[.=$d][1]/parent::ad/child::head
let $para := $search[.=$d][1]/parent::ad/child::p
let $note := $search[.=$d][1]/parent::ad/child::note
let $pb := $search[.=$d][1]/preceding::pb[1]
order by $d
 return
<ad>
<statistics>
Showing Result: {$count} / {count($sorted_result)}
</statistics>
<information_source>
{$journal}
<publication>Volume {data($volume)}, Issue {data($issue)}</publication>
</information_source>
{$head2}
<description>{$para}</description>
{$note}
<information>Source from page {$pb}</information></ad>
            )
};

declare function local:main() as node()?
{
    session:create(),
    let  $search := xs:string(request:get-parameter("search", ()))
    return
                if ($search) then local:guess($search)
                        else
                                <p>You have not entered any search terms!</p>
};

<html>
    <head><title>Collection Advertisement Testing Page</title></head>
    <body>
        <form action="{session:encode-url(request:get-uri())}">
            <table border="0">
                <tr>
                    <th colspan="2">Welcome to My XQuery Web Application Testing</th>
                </tr>
                <tr>
                    <td>Type in Your Search Term:</td>
                    <td><input type="text" name="search" size="3"/></td>
                </tr>
                <tr>
                    <td colspan="2" align="left"><input type="submit"/></td>
                </tr>
            </table>
        </form>
        { local:main() }
        <p><small>View <a href="guess.xql?_source=yes">source code</a></small></p>
    </body>
</html>



======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
http://x-query.com/mailman/listinfo/talk



Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.