[topicmapmail] xpath: stop at first match
Lars Marius Garshol
larsga at garshol.priv.no
Mon Jul 31 12:23:31 EDT 2006
* Carlo Moneti
>
> Right. But my issue is this example (any path will do):
> /topicMap/topic[@id='$id']
If you want to do this you should use xsl:key, if you are in XSLT.
But in any case it is *very* likely that you are doing something
that's not really a good idea. Processing XTM with XSLT/XPath is,
well, not a good idea. It's extremely painful, you are pretty much
guaranteed not to interpret the XTM document correctly, and it really
brings you none of the benefits of using Topic Maps in the first
place, since you then have to reimplement all of the functionality
yourself.
So I strongly recommend using a Topic Maps engine instead of working
directly on the XTM.
> 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?
No, there isn't. The reason is that all (or nearly all) XPath
implementations build a full document tree before they start
evaluating the XPath expression, and so by the time the XPath is
executed the whole document has already been read.
--
Lars Marius Garshol, Ontopian http://www.ontopia.net
+47 98 21 55 50 http://www.garshol.priv.no
More information about the topicmapmail
mailing list