Semantic MediaWiki and related extensions
|
Semantic MediaWiki provides a SchemaFilter
to help developers define specific conditional aspects of a schema.
The following examples show the expected format for how to define a condition which is tested and hereby permits the code to decide whether it is a true statement or not for those tested values. Aside from the if
+ keyword
notation, some statements allow to clarify the requirements when more than one value is given or required by using the following expressions oneOf
, anyOf
, and allOf
(borrowing the semantics from swagger.io and json-schema.org).
Building compsite filters is possible as well by combining different condition statements as the next example shows where the first condition expects a specific namespace
while the category
condition requires "allOf" its conditions to be met so that the entire composite block (which each individual filter) is to be true only when all requirements are fulfilled.
The following filter conditionals are provided by default:
category
conditional is implemented in CategoryFilter
namespace
conditional is implemented in NamespaceFilter
property
conditional is implemented in PropertyFilter
To be able to use above filters without modifications the following format is expected from a schema that relies on those conditionals. A single filter should be declared with something like:
While expressing a composite filter should follow:
It should be noted that it is possible to define a schema without a specific "rule_name_x" but it will create a disadvantage when trying to identify which rule was applied later in a production system when there are many possible rules to be filtered.
Some conditionals (category, namespace, property) can clarify their intention for testing a condition by using extra attributes such as oneOf
, anyOf
, allOf
. For an understanding of the semantics, please consult the swagger.io and json-schema.org.
The SchemaFilter
describes an interface for a specific filter implementation.
As with the example above, different filters can be combined to narrow the match pool of values to be tested against. To support composite filters any filter can be attached to another as a so called "node" filter to build something similar to a decision tree that is recursively traversed hereby tests on matches left from the previous filter.