[xquery-talk] What does [.] do.

Ihe Onwuka ihe.onwuka at gmail.com
Mon Feb 10 03:20:24 PST 2014


On Mon, Feb 10, 2014 at 11:14 AM, Michael Kay <mike at saxonica.com> wrote:
>
> On 10 Feb 2014, at 09:59, Ihe Onwuka <ihe.onwuka at gmail.com> wrote:
>
>> On Mon, Jan 27, 2014 at 1:59 PM, Ghislain Fourny <g at 28.io> wrote:
>>> Hi Ihe,
>>>
>>> You are right that it is a filter expression.
>>>
>>> However, I think [.] is not very common in "real world" code, except maybe for very precise use cases (like filtering out empty strings, etc). Usually you would put either a position or a boolean predicate inside a filter expression -- not just a context item expression.
>>>
>>> What [.] does, if I am not missing anything, is that it only keeps:
>>> 1. Numerics equal to their position in the left-hand-side sequence
>>> and
>>> 2. Non-numerics that have an Effective Boolean Value of true, like non-empty strings, nodes, the true boolean, etc.
>>>
>>> Example:
>>> (1, 2, 4, 3, 5, "", "foo", <a/>, true, false)[.]
>>>
>>> returns
>>>
>>> 1 (position matches)
>>> 2 (position matches)
>>> 5 (position matches)
>>> foo (EBV = true)
>>> <a/> (EBV = true)
>>> true (EBV = true)
>>>
>>
>> In Zorba it does - but is that right?
>
> It's right if there is a context item, which is context-dependent....
>
> For true and false in this example, you probably meant true() and false().
>

No. I am aware of that distinction. I was quoting the results obtained
from the example that was quoted.

ihe at ihe-ThinkPad-T410:~/film$ zorba -q '(1, 2, 4, 3, 5, "", "foo",
<a/>, true, false)[.]'
(no URI):1,41: static warning [zwarn:ZWST0008]: "false": has been
deprecated; use "fn:false()" instead
(no URI):1,35: static warning [zwarn:ZWST0008]: "true": has been
deprecated; use "fn:true()" instead
<?xml version="1.0" encoding="UTF-8"?>
1 2 5 foo<a/>truei



More information about the talk mailing list