[xml] Identifying which XPath expression matched a node


I'm hoping to get an answer on how I can identify which XPath expression returned a particular node.

Here's the thing:

Let's say I have a program that can scan XML documents and search them using XPath.

Now, the program can accepts "search" requests from clients who "register" an XPath expression with it, and afterwards, receive the individual results of their queries. So, the program must have a way to match query results to the client that requested that query.

For efficiency reason, the program will process the document only once. The idea therefore is to combine the individual expressions into a single expression and use that on the document. (Obviously, I'm assuming here that evaluating N expressions as a single combined one is X times "more efficient" than evaluating each individual expression in turn, where X is N or maybe N/2 or something similar.)

So given three queries:

Client A -> expr1
Client B -> expr2
Client C -> expr3

the program will evaluate the combined XPath expression expr1 | expr2 | expr3 on the document.

Now, when the program receives the result of the combined query how can it tell which node to return to which client? Does a node "know" which XPath expression was used to match it?


- Peter

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]