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

Michael Sokolov msokolov at safaribooksonline.com
Mon Jan 27 07:04:38 PST 2014


What I have usually seen in that case is:

(xs:string(readingMaterial),xs:string(publication))[1]

which allows for prioritization in case there are actually both for some 
unforeseen reason

On 01/27/2014 09:55 AM, Ihe Onwuka wrote:
> I am using one transformation for two different data sources with two
> different schemas.
>
> One site may call a resoure readingMaterial another site may call the
> same concept a publication, but they are otherwise similar and you may
> want to treat them as such.
>
> (xs:string(readingMaterial),xs:string(publication))[.]
>
> when you know they are mutually exclusive in your document but you
> want to process them in the same way.
>
>
>
> On Mon, Jan 27, 2014 at 2:45 PM, Michael Kay <mike at saxonica.com> wrote:
>> On 27 Jan 2014, at 13:59, 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.
>>>
>> I mention on p648 of my XSLT /XPath book that the expression
>>
>> some $s in $S satisfies CONDITION
>>
>> is equivalent to
>>
>> exists(for $s in $S return boolean(CONDITION)[.])
>>
>> though I don't suppose that really counts as a use case.
>>
>> I think the only case I've used in anger is probably count(tokenize($x, ' ')[.]) which eliminates the zero-length tokens that can arise at the start and/or end of the sequence.
>>
>> Michael Kay
>> Saxonica
>>
>>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk



More information about the talk mailing list