Query on referenced entities?

Hello All


I was wondering if it is possible to formulate a query in Tamino to find a path between referenced entities.
I have several “nodes” in one XML-document which are connected by references. Now I want to pick one and see, if a specified second node is connected to the first one by a unspecified number of nodes and if yes, to get the path between them.
Example:















Now if I pick A as the start node and C as the end node I would like to get a document with the nodes A B C in it.

The main problem here is that the number of nodes between the starting and ending node is unknown. Any suggestions are appreciated, I have no restrictions concerning query languages or APIs. (At first I thought to use XQuery together with selfdefined server extensions but apparently that

I suspect that when you say “entities” you mean “elements”.

This is a typical example of a recursive query. Recursive queries are a big problem for all database systems because the performance is open-ended. In the XQuery language, arbitrary recursive queries can be expressed using user-defined functions, but these are not yet available in Tamino.

It might be easier to code this in XSLT, or perhaps even in a low-level procedural language using DOM interfaces. There are many published algorithms for graph traversal that you can apply to this problem (the optimum solution depends on how dense the linkages are in your graph) and they are all expressed in procedural code, so this is a case where a procedural language such as Java may be more appropriate than a declarative language such as XQuery or XSLT, if you want control over the performance.

Michael Kay