Reputation: 23
I know that I can use xpath to perform joins using the "|" operator. Is there a way to perform semi-joins in xpath like for example:
book[author = article/author]/title
If semi-joins exist, what would the output of the query above look like. Does it just output the title element of each book that has an author who also authored an article?
Upvotes: 2
Views: 578
Reputation: 6956
The given query would return the title of each book that contains an article that has been authored by that book's author. Thus, in the context of books
below, the only thing returned would be the title
element with the text "title 0".
<books>
<book>
<title>Title 0</title>
<author>Petri, M</author>
<article>
<title>Title 1</title>
<author>Petri, M</author>
</article>
<article>
<title>Title 2</title>
<author>Butcher, P</author>
</article>
</book>
<book>
<title>Title 3</title>
<author>Butcher, P</author>
<article>
<title>Title 4</title>
<author>Petri, M</author>
</article>
</book>
</books>
Upvotes: 0
Reputation: 167706
Maybe you want //book[author = //article/author]/title
. With your current attempt book[author = article/author]
the article
elements would need to be children of the book
element which does not seem likely.
Upvotes: 2