Reputation: 225
I fail to write a query displaying the relevant information in Semantic Mediawiki.
Let's say there are two main properties for an author: Quotes
and AuthorOf
, and one for a book: HasQuotedAuthor
.
Suppose that there are three authors: Coleridge, Byron and Dickens.
[[Quotes::Byron]]
.[[AuthorOf::The first kiss of love]]
and [[AuthorOf::The Dream]]
[[AuthorOf::A Christmas Carol]]
and [[AuthorOf::Oliver Twist]]
.[[HasQuotedAuthor::Coleridge]]
.How can you build a query on the page of Coleridge to get a table including the authors who quote him and only the relevant books where Coleridge is actually quoted?
Upvotes: 1
Views: 116
Reputation: 8520
I created these pages and queries for you here: http://smw.referata.com/wiki/Coleridge
You are asking for any author of a book where {{PAGENAME}}
(in this case Coleridge) is quoted. Your query would look like this:
{{#ask: [[Author of::<q>[[HasQuotedAuthor::{{PAGENAME}}]]</q>]] }}
and the result will be: Byron, Dickens
Or you could print books and authors at the same time:
{{#ask:[[HasQuotedAuthor::{{PAGENAME}}]]
|?-Author of
}}
The minus sign before Author of
indicates a reverse property. In other words we want to show authors having authored this book. We could also have used this query to create a list similar to the first one, by just hiding the first column:
{{#ask:[[HasQuotedAuthor::{{PAGENAME}}]]
|?-Author of
|format=ul
|mainlabel=-
}}
Upvotes: 2