user1453786
user1453786

Reputation: 225

Narrow a query in Semantic MediaWiki

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.

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

Answers (1)

leo
leo

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

Related Questions