[XQZone General] query works in use cases demo screen, not
inxqy file
DuCharme, Bob
bducharme at innodata-isogen.com
Thu May 11 11:13:19 PDT 2006
Thanks, David, that worked!
Bob (writing from about 6 miles away, in Ivy)
(And thanks Darin)
-----Original Message-----
From: general-bounces at xqzone.marklogic.com
[mailto:general-bounces at xqzone.marklogic.com] On Behalf Of David Sewell
Sent: Thursday, May 11, 2006 12:27 PM
To: General XQZone Discussion
Subject: Re: [XQZone General] query works in use cases demo screen, not
inxqy file
The problem with the form of the query that returns an <html> element is
that you're declaring a namespace on the <html> element, so within the
query ML Server is expecting the XPath elements to be in html namespace.
You could just delete the namespace from <html>, or another workaround
that works with ML Server (but is not compatible with the current XQuery
Candidate Recommendation, I don't think) would be to put at the top of
your query:
declare namespace null = ""
and then put a "null:" prefix in front of your XPath steps, e.g.:
{$doc/null:recipeml/null:recipe/null:head/null:title/text()}
That will give the desired output.
On Thu, 11 May 2006, DuCharme, Bob wrote:
> I've loaded some data into MarkLogic (see
> http://www.xml.com/pub/a/2005/03/02/xquery.html for more on the data),
> and the following works fine from http://localhost:8000/use-cases/:
>
>
>
> for $doc in collection('recipes')
>
> where $doc/recipeml/recipe/head/yield > 20
>
> return $doc/recipeml/recipe/head/title/text()
>
>
>
>
>
> The following script, however doesn't work:
>
>
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>
> <head><title>Food for a Crowd</title></head>
>
> <body>
>
> <h1>Food for a Crowd</h1>
>
> {
>
> for $doc in collection('recipes')
>
> (: where $doc/recipeml/recipe/head/yield > 20 :)
>
>
>
> return
>
> <p><a href="{document-uri($doc)}">
>
> {$doc/recipeml/recipe/head/title/text()}
>
> </a></p>
>
> }
>
> </body></html>
>
>
>
> (I commented out the WHERE clause to simplify it.) The titles are not
> showing up. The output of the for loop looks like this:
>
>
>
> <p><a
> href="c:/dat/xquery/recipeml/_Mexican_Five_Layer_Dip_.xml"></a></p>
>
> <p><a href="c:/dat/xquery/recipeml/Walnut_Squares.xml"></a></p>
>
> <!-- etc. -->
>
>
>
> (If I don't comment out the WHERE clause, I don't even get the "a"
> elements.) Why would "return $doc/recipeml/recipe/head/title/text()"
> work in an ad hoc query from the use cases screen but not from within
a
> script?
More information about the General
mailing list