I'm still trying to make my wiki more "dynamic" in order to get rid of duplicated data. In my previous question I was asking how I could bind multiple pages and retrieve properties through bound pages. Since that question is already resolved for simple cases (however I don't like my solution there much), I would like to make it work for tables. let's consider the same page and property structure I mentioned in my question again, thus the following code
{{#ask: [[Category:Venues]] [[Self name::Heineken Music Hall]]}}
{{#ask: [[Category:Cities]] [[-Ref city.Self name::Heineken Music Hall]]}}
{{#ask: [[Category:Countries]] [[-Ref country.-Ref city.Self name::Heineken Music Hall]]}}
retrieves the venue, city (Amsterdam) and country (Netherlands) using inline queries. However I'm not sure if such an approach is possible for tables. As far as I know, #ask
can generate a table generating columns out of direct properties :
{{#ask: [[Category:Live events]]
| ?Self date = Date
| ?Ref venue = Venue
| mainlabel = -
}}
Output:
+-----------------+---------------------+
| Date | Venue |
+-----------------+---------------------+
| 3 December 2012 | Heineken Music Hall |
+-----------------+---------------------+
I would also like to add the City and Country columns. The problem is, as I mentioned above, the city and country properties are not put directly into the Venue page so the #ask
function might use inline subqueries. But I can't make it work:
{{#ask: [[Category:Live events]]
| ?Self date = Date
| ?Ref venue = Venue
| ?WHAT_EXPRESSION_HERE? = City
| ?EVEN_MORE_COMPLEX_EXPRESSION_HERE? = Country
| mainlabel = -
}}
The first thing I'm thinking about is using templates using the format = template
and template = TEMPLATE_NAME
. I managed to extract the bound city using this approach by creating the required template and parsing {{{1}}}
... parameters, but I cannot seem to extract country (simple to extract: date, venue; complex: city; not able: country). Also using the templates approach seems to be fragile and not very consistent to me.
Is it possible to specify subqueries/expressions rather than properties for tables to extract properties from indirectly bound pages in Semantic MediaWiki (probably never using templates)?