Hi Javier,
$entries is an attribute: if $employees/@count is 10, <td>{ $entries }</td>
will return <td count="10"></td>.
Instead, you should be converting @count to a string:
$entries := $employees/@count/fn:string()
You should do the same for $fullname: text() doesn't always do what you'd
expect, and it returns a text{} node, not a string:
$fullname := $employees/fn:string()
Thanks.
-jb
From:
<[email protected]<mailto:[email protected]>>
on behalf of Javier Lizarraga
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Wednesday, December 9, 2015 at 12:56 AM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] simple xQuery Web Application
I using xquery… specifically modifying the World’s Leader xquery application,
the index.xqy file. Here is the same code:
I get no value for @count
let $emp := local:getEmployees()
for $employees in $emp/search:facet/search:facet-value
let $fullname := $employees/text()
let $entries := $employees/@count
let $urlBuild := fn:concat("fullName=", $fullname, "&", "workDate=",
"10-1-2015")
return (
<tr>
<td colspan="10"><hr/></td>
</tr>,
<tr>
<td><b><a
href="http://localhost:8077/bycountry.xqy?{$urlBuild}">{$fullname}</a></b></td>
<td>2015-08-04</td>
<td>2015-08-10</td>
<td><b>{$entries}</b></td>
<td>{local:getTotalHours($fullname)}</td>
<td>{local:getAverageHours($fullname)}</td>
<td>{local:getMaxHours($fullname)}</td>
</tr>,
<tr>
<td colspan="10" class="summary">$description...</td>
</tr> )
}
</table
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of David Lee
Sent: Tuesday, December 8, 2015 8:03 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] simple xQuery Web Application
>> The following code works in the Query Console but does not work in my xQuery
>> application.
What is your application? (What library/program etc)
The results shown look correct for the first return
You are returning a sequence of sequences which will flatten to a single long
sequence.
Some XQuery APIs' dont handle sequence results ( or do not using the most basic
interface).
-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 812-482-5224
Cell: +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Javier Lizarraga
Sent: Tuesday, December 08, 2015 8:06 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] simple xQuery Web Application
Hello David,
Related question…
I am having issues accessing an element attribute in search:facet…
The following code works in the Query Console but does not work in my xQuery
application.
let $emp := search:search("(Bachala OR Chakka OR Kompelly OR Lasseter)",
$options)
for $employees in $emp/search:facet/search:facet-value
let $fullname := $employees/text()
let $entries := $employees/@count
return ($fullname, $entries, $emp)
==>
Vishnu Bell
47
<search:responsesnippet-format="empty-snippet"total="91"start="1"page-length="100"xmlns:search="http://marklogic.com/appservices/search">
<search:facetname="FULL_NAME"type="xs:string">
<search:facet-valuename="Vishnu Bell"count="47">
Vishnu Bell
</search:facet-value>
<search:facet-valuename="Bala Bell"count="36">
Bala Bell
</search:facet-value>
<search:facet-valuename="Stephen Bell"count="8">
Stephen Bell
</search:facet-value>
</search:facet>
<search:qtext>
(Bachala OR Chakka OR Kompelly OR Lasseter)
</search:qtext>
</search:response>
Advice would be greatly appreciated.
Javier
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of David Lee
Sent: Thursday, December 3, 2015 11:51 AM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] simple xQuery Web Application
Thanks that works. So, the * is saying any namespace.
Yes, (as of XPath 2.0)
/element == element in no namepace
/*:element == element in any namepace
Very useful for quick 'one off's when you dont want to bother with the
neamespace decl,
but its a bad habbit to get into for production code -- you can end up
selecting elements in unexpected places
that you didnt intend.
-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 812-482-5224
Cell: +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general