Subobjects¶
aka Semantic Internal Objects1
Warning
Definition: « Subobject »
A subobject is an independent and uniquely identifyable resource in Semantic MediaWiki with an arbitrary set of properties hosted on wiki pages to which they hold a has_subobject
relationship.
Quelle: Eigene Definition
Function¶
Subobjects are a very important concept in semantic modelling as they allow for the expression of n-ary-relationships between a subject (the wiki page) and its objects where the subobject serves as blank node resource.
Example
Example
With subobjects you can express on an employee page the different times where she worked for some projects.
→ Try for yourself
How would you represent the above use case with default SWM language primitives (categories / properties / pages)?
How could you state the following project memberships for an employee “Matthias”:
The above example becomes even more complicated when the project role is added, e.g.
Tip
Task
Think about other use cases in which subobjects allow for expressing real-world situations in more natural (ie. appropriate) ways. Write them down and illustrate the representation with subobjects for one use case in form a conceptual graph.
Characteristics¶
Subobjects are not defined on distinct pages nor have a separate namespace but are defined on wiki pages in the main namespace.
A wiki page may define as much subobjects as necessary.
Subobjects can have an explicitly specified identifier – otherwise, SMW creates an unique identifier.
Properites used in a subobject “belong” to it and not to the page in which a subobject is embedded in.
A subobject can hold as many property-value pairs as needed;
~> it groups them together and links them trough the subobject to page the subobject is embedded in without the necessity of creating auxiliary pages.
A subobject embedded on a page resolves into a pagename – has_subobject – subobject_identifier
relationship2, where subobject_identifier
is either the explicitly set subobject name or an internal identifier created by SMW to give the subobject a unique name through which it can be identified
Subobjects can be queried for in #ask
queries
Syntax¶
Subobjects are created with the parser function #subobject
Please note:
Like the #set
parser function the #subobject
parser function is a form of silent annotation: → it adds values to properties but does not print anything to the page.
Querying Subobjects¶
In some cases it might be necessary to display the subobject data directly after they have been defined on a page.
This can be achieved with an #ask
query asking for the inverse of the has subobject
property, i.e., the object value of the subobject given the hosting page name.
Example
Example
Defining two subobjects with identifiers first
and second
:
Then to print out the subobjects one would insert this code on the same page:
Note the “-
” symbol which is necessary to make the query work (see Inverse Properties for more information).
Show Properties of a Subobject’s Parent Page¶
In some cases one might not only want to query for subobject data but also for “usual” properties that are defined on the subobject’s parent page. The process to do that contains the following steps:
- Query for a property of a subobject.
- Use
format=template
. - Add another query in this template where you ask for
[[Has subobject::{{{1}}}]]
.
Has subobject
returns the parent page of a subobject. The subobject is queried in the first query and passed on to the template as{{{1}}}
.
Example
Example
In Template:YourTemplate
add the following:
Please note: |?YourSubobjectProperty1
and |?YourSubobjectProperty2
will be passed to the template as parameters too; they can be accessed via their index, ie. {{{2}}}
and {{{3}}}
.
Tip
Task:
Work through the full offical documentation of Semantic MediaWiki subobjects https://www.semantic-mediawiki.org/wiki/Subobject and try to understand the notation and rationale befind subobjects and how to use them.
If you haven’t complete Task 1 – yet is the time to do…!
Note
Subobjects and its Friends…
Subobjects become extremely usefull when used in conjunction with multi-instance templates and Semantic Forms.