You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Michael Kastner <ka...@galt.de> on 2005/03/24 15:40:44 UTC
Query question
Hello,
I have a question regarding xquery.
I execute the following query:
string(/bank[name='Dresdner Bank AG']/name)
Against these documents;
<bank>
<name>Dresdner Bank AG</name>
</bank>
<bank>
<name>Deutsche Bank</name>
</bank>
<bank>
<name>Deutsche Bank</name>
</bank>
<bank>
<name>Some dummy bank</name>
</bank>
The query returns these resources:
<xq:result
xmlns:xq="http://xml.apache.org/xindice/Query"
xq:col="/db/banks" xq:key="0100007f626f1e1500000102ca77bb76" />
<xq:result
xmlns:xq="http://xml.apache.org/xindice/Query"
xq:col="/db/banks" xq:key="0100007f626f1e1500000102ca7c4773" />
<xq:result
xmlns:xq="http://xml.apache.org/xindice/Query"
xq:col="/db/banks"
xq:key="0100007f626f1e1500000102ca8142c3">Dresdner Bank AG</xq:result>
<xq:result
xmlns:xq="http://xml.apache.org/xindice/Query"
xq:col="/db/banks"
xq:key="0100007f626f1e1500000102d468b1d9" />
What I would expect is only one resoure as a result: the resource
containig the name "Dresdner Bank AG".
Am I missing something?
Sincerely
Michael Kastner
Re: Query question
Posted by Todd Byrne <by...@cns.montana.edu>.
Try this:
/bank/name[text()='Dresdner Bank AG']
Not sure why the original query doesn't work(probably something to do
with the string function not correctly filtering off the empty results)
, but I find that returning whole nodes like in this case 'name' works
allot better in the long run. The way xindice api is setup you still
need parse the string anyways then extract the text.
Todd
Michael Kastner wrote:
> Hello,
>
> I have a question regarding xquery.
>
> I execute the following query:
>
> string(/bank[name='Dresdner Bank AG']/name)
>
> Against these documents;
>
> <bank>
> <name>Dresdner Bank AG</name>
> </bank>
> <bank>
> <name>Deutsche Bank</name>
> </bank>
> <bank>
> <name>Deutsche Bank</name>
> </bank>
> <bank>
> <name>Some dummy bank</name>
> </bank>
>
> The query returns these resources:
>
> <xq:result
> xmlns:xq="http://xml.apache.org/xindice/Query"
> xq:col="/db/banks" xq:key="0100007f626f1e1500000102ca77bb76" />
> <xq:result
> xmlns:xq="http://xml.apache.org/xindice/Query"
> xq:col="/db/banks" xq:key="0100007f626f1e1500000102ca7c4773" />
> <xq:result
> xmlns:xq="http://xml.apache.org/xindice/Query"
> xq:col="/db/banks"
> xq:key="0100007f626f1e1500000102ca8142c3">Dresdner Bank AG</xq:result>
> <xq:result
> xmlns:xq="http://xml.apache.org/xindice/Query"
> xq:col="/db/banks"
> xq:key="0100007f626f1e1500000102d468b1d9" />
>
> What I would expect is only one resoure as a result: the resource
> containig the name "Dresdner Bank AG".
>
> Am I missing something?
>
> Sincerely
>
> Michael Kastner