[topicmapmail] xpath: stop at first match

Carlo Moneti cmoneti at twcny.rr.com
Mon Jul 31 10:15:23 EDT 2006


On 2006.07.30 15:54 G. Ken Holman wrote:
> XSLT and XPath questions would be better posted to the following list:
> 
>   http://www.mulberrytech.com/xsl/xsl-list
> 
> There are a number of subscribers who would enthusiastically respond to 
> such questions.
> 
> There is also an *excellent* XSLT FAQ at:
> 
>   http://www.dpawson.co.uk

Thanks for the links. But my question is really xpath specific. I'm not 
using XSL nor XSLT. I am using php5.1.4 and the simpleXML 
functions---based on libxml2.

> If you are using something like "//thing", then "//thing[1]" will not 
> work for you because it will find the first child *at every level of 
> the tree* ... the way around this is (//thing)[1], but as always, the 
> use of "//" is terribly inefficient.

Right. But my issue is this example (any path will do):
/topicMap/topic[@id='$id']
The point is that I know there is only one possible match. So I would 
like the processor to stop upon finding a match and return the value, 
rather than needlessly scanning the rest of the document (in this case) 
or the current document fragment. I expected there would be a syntax for 
doing this. I haven't found it. Is there a way?

Thanks,
Carlo


More information about the topicmapmail mailing list