Modul:Wb/dok

Frå Wikipedia – det frie oppslagsverket

Dette er dokumentasjonssida for Modul:Wb

The purpose with this module is to make a very simple way to identify an entity and extract information from that entity. There are three core methods to get to an entity. First one is to simply not identify any entity, which will imply using the connected item. Second one is to explicitly identify an item, which will look up that specific item. Third one is to use a path statement to point to the correct item.

Path definition[endre wikiteksten]

A path definition is like a path in a directory structure, a xpath statement or a css class selector. The path is broken up at each forward slash. As any such path there is a root, where a dot signify "here", a double dot signify "parent" (or better "previous"), and several dots "grandparents" to some level. A single dot is implied in front of each segment if there is no explisit initial entity statment.

Each segment has a final selected state for all the statements. Any statement that isn't selected will not be included in the final set. A set can expand due to inclusion of several parallell statements, and contract because some of them fail to be selected.

A first level of subspecifier that can lead to deselection are properties themselves. Only properties that exist can be selected. Further de-/selection is done by diving into qualifiers, sources or attributes. Qualifiers are marked with an colon (:) and then a property marker, while sources are marked with the string "source:" and then the property. Inside those the traversal is as for an ordinary statement.

There can be a subpath down to a specific attributes. Attributes are marked with a dot (.) and then their name. The attribute structure is the same as the one defined for the statements in Wikibase. If the attribute can't be located, then the statement become deselected. It is not necessary to traverse all the way down, but later on it is necessary that the remaining structure can be rendered.

A pseudo attribute is a bit special, it is a way to access a value that isn't easilly interpreted in a path statement. A few such exist, like "type" and "rank". Likewise there are functions that are like pseudo attributes that takes arguments. Pseudo elements are marked with a colon (:).

There can be additional eksplisitt selectors within square brackets. The results from the expressions within them are evaluated in a boolean context, and the final result says whether the statement should be included or excluded.

Each new segment in the path marks the traversal of a claim to another item, it gets a new epoch. Each such traversal is only done if the statement is selected. If all statements gets deselected the path fails and returns empty.

The following will select the municipality Sør-Aurdal (Q48414). (Returns a set of a single item id, that is the simplest representation of an item.)

{{#invoke:Wb | load | Q48414 }}
{{#invoke:Wb | load | Q{Sør-Aurdal} }}

If run from the article page itself the following should be sufficient. (Returns a set of a single item id, that is the simplest representation of an item.)

{{#invoke:Wb | load | . }}

The following will select the siblings within the enclosing administrative territorial entity for the municipality Sør-Aurdal (Q48414). (Returns a set of a single item id, ie. the data value, ie. the items pointed to on the simplest representation for an item.)

{{#invoke:Wb | load | Q48414/P131/P150 }}
{{#invoke:Wb | load | Q{Sør-Aurdal}/{located in the administrative territorial entity}/{contains administrative territorial entity} }}

The following will only find the best coat of arms for the municipality Sør-Aurdal (Returns a set of a single string, ie. the name of the file.)

{{#invoke:Wb | load | ./P94! }}
{{#invoke:Wb | load | ./{coat of arms image}! }}

A segment can hold additional selectors that the item must satisfy for the statement to be accepted. Those can identify other entities and statements.

This finds the containing administrative area that has a coa of svg-format.

{{#invoke:Wb | load | Q48414/P131 [P94 $= .svg]}}
{{#invoke:Wb | load | ./{located in the administrative territorial entity} [P94 $= .svg]}}

Or perhaps we want the label for those areas in Deutsch

{{#invoke:Wb | load | Q48414/P131:label(en) [P94 $= .svg]}}
{{#invoke:Wb | load | ./{located in the administrative territorial entity}:label(en) [P94 $= .svg]}}