Jump to: navigation, search

At first, it looked like this was going to be quite a puzzle. The fictional scenario is this:

Imagine that you have pages about crime novels, with information about street names being stored on the page and/or in subobjects that describe different book chapters.
You want to create a query form that returns the novels in which a given street is named. It should list all the relevant novels and as part of those results, you want to have the first five relevant book chapters together with a brief description.

The trick is to introduce a subquery in the template for subobjects (step 2). Although the value required by this subquery ("High Street") is not normally passed to the template, we are fortunate in having "userparam"!

Step 1 - the query
{{#ask: [[Category:Crime novels]] [[Street::High Street]] OR [[Category:Crime novels]] [[Has subobject::<q>[[Street::High Street]]</q>]]
|?Has subobject
|named args=yes
|userparam=High Street
Step 2 - the template

Template:StreetCrime should include

{{#if:{{{?Has subobject|}}}|
{{#ask: [[-Has subobject::{{{Page|}}}]] [[Street::{{{userparam|}}}]]
|?printout parameters, etc.

Quite simple really, though I haven't tested this yet, let alone the more complex situation in which multiple values from multiple properties are included in the argument.

Since SMW, data refresh is taking a lot longer than before - not one day but more than five so far (80%). Meannwhile, memory issues are being reported, especially

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8208 bytes) in .../extensions/SemanticMediaWiki/includes/storage/SQLStore/SMW_Sql3SmwIds.php on line 835 

somewhat outdated

Semantic Internal Objects (extension) Subobject (SMW since 1.7.0)
Type of annotation silent annotation silent annotation
parser functions: #set_internal and #set_internal_recurring_event
followed by SIO property name
followed by unique ID
| type of address= street
| street number=10
| street name=Parks Road
| postcode=OX1 3QD
| city=Oxford
| country=UK

|type of address=postal
| ...
{{#set_internal_recurring_event:Is instance of
|property=Has date
|start=January 4, 2010
|end=June 8, 2011
{{#subobject:street address
| street number=10
| street name=Parks Road
| postcode=OX1 3QD
| city=Oxford
| country=UK

{{#subobject:postal address
| ...
ID ID is autonumbered:

<page name>#1, <page name>#2, etc.

ID is assigned manually:

<page name>#street address, <page name>#postal address

Note: Autonumbering can be achieved through the parser function "variable". See below.

multiple values comma-separated lists are possible (no other delimiter is allowed):
{{#set_internal:Is president of
|Has name=Ulysses S. Grant
|Has vice president#list=Schuyler Colfax, Henry Wilson
does not allow for multiple values (?)
SMW integration cannot be combined with regular #ask queries can be combined with regular #ask queries
Example query: ... ...
Limitation Subobjects and SIOs do not (automatically) inherit the properties of the parent page. Categories are not inherited either nor is it possible for them to be assigned manuually. This means, for instance, that querying on a category will not yield any results from subobjects or SIOs.


Define the variable:

{{#vardefine: #
    | {{  #expr: {{ #var: # | 0 }} + 1  }}

and add the variable at the appropriate place in the syntax:

{{#subobject: {{ #var: # }}
    | property = value...