[topicmapmail] xpath: stop at first match
Carlo Moneti
cmoneti at twcny.rr.com
Wed Aug 2 12:35:46 EDT 2006
On 2006.08.01 21:44 G. Ken Holman wrote:
> At 2006-08-01 21:05 -0400, Carlo Moneti wrote:
>> A "stop on first match" option in xpath strikes me as a highly useful
>> feature. And, in my case, my code would be tighter and more
>> consistent. I'm sorry to get confirmation that it doesn't exist.
>
> In my opinion, W3C and ISO standards properly specify results, not
> behaviours. Products compete on the implementation of their own
> behaviours to produce the specified results.
See bottom
> Two people, myself included, have told you that the following specifies
> what you want:
>
> /topicMap/topic[@id='$id'][1]
Well, not really. Also, I was well aware of this option beforehand.
Frankly, the position() function is not relevant, not in function or
intended purpose. See below
> It would be inappropriate for a standard to dictate *how* that is
> implemented. In the XSLT world the Saxon processor returns the first
> without looking beyond, while I believe (though I'm not positive) the
> XT processor obtains all and then returns the first of them.
That's interesting. Then Saxon must provide a setting or query syntax for
this, I presume?
> If the implementation of XPath you are using is not lazily implemented,
> then change it or obtain another that is lazily implemented ... in my
> opinion the specification is not to blame or to be "fixed".
I only suggested that a "stop-on-first-match" option is very useful and
perhaps worthy of being added to the xpath spec.
I agree that a spec should not include how a feature is to be
implemented. But I'm suggesting a new feature. You bring up an
interesting semantic (if not philosophical) issue in your distinction
between specifying "results" rather than "behavoirs"---by which I'm
interpreting (from a user's perspective) as "features" and
"implementation details". As I understand, the option to return only one
item is a "feature" by virtue of the fact that the spec requires that
functionality and the query syntax to support it. Apparently, the
community has not much noticed that when querying for a known unique
value it would be desirable to be able to tell the processor to stop on
first match. If and when they do, they may wish to elevate such
functionality to a "feature" by assigning a syntax for the option and
adding it to the spec. If it's an option, it is by definition a feature,
not an implementation detail. In fact, it can only be implemented as an
option because only the programmer knows when a query is for a unique
item.
Thanks,
Carlo
More information about the topicmapmail
mailing list