Help:Schema definition

From semantic-mediawiki.org
Jump to: navigation, search
Schema definition
Provide information about user-defined properties and categories
Image / Video collection
Keywords
Table of Contents

SMW 2.4 introduces the schema definition feature1 to provide information about user-defined properties and categories in a JSON format so that entity descriptions can be manged more easily and be accessible through a centralized method (with the intention to change specifications more easily by either a user or any from of program that can interact with the JSON format).

Features and limitations

  • Properties and categories defined by a schema are blocked by the SchemaManager from manual editing (incl. moving and deletion) to ensure that changes are in sync with the schema definition
  • Changes to an entity are automatically published using the SchemaUpdateJob
  • MW's JsonContentHandler API can be used the update/change the schema definition in a structured way
  • Type validation (e.g. use of a correct type annotation etc.) is not explicitly carried out by the SchemaManager, display of individual errors are handled by the corresponding property page (for an overview of possible mismatches a query like: [[Property:+]][[Has processing error text::+]] can be used)
  • Properties and categories not part of a schema will remain "free" in how they can be defined

Format

Identifiers used within the format are mapped to:

  • 'type' as 'Has type',
  • 'importedFrom' as 'Imported from'
  • 'subpropertyOf' as 'Subproperty of'
  • 'correspondsTo' as 'Corresponds to'
  • 'constraintOf' as 'Allows value' or 'allowsValue' as 'Allows value'
  • 'fields' as 'Has fields'
  • 'units' as 'Display units'

Example

{
    "description": "Schema list for Semantic MediaWiki",
    "version": "0.1",
    "properties": [
        {
            "property": "Has description",
            "type": "Text",
            "importedFrom": "dc:description",
            "subpropertyOf": "Has text",
            "categories": [
                "Schema category2"
            ]
        },
        {
            "property": "Has additional description",
            "redirectTo": "Has description"
        },
        {
            "property": "Has wattage",
            "type": "Quantity",
            "units": "kW",
            "correspondsTo": [
                "1 W, Watt, Watts",
                "0.001 kW",
                "0.0013410220 hp, bhp, horsepower"
            ],
            "categories": [
                "Category one",
                "Category two"
            ]
        }
    ],
    "categories": [
        {
            "category": "City",
            "importedFrom": "dcterms:Location",
            "subcategoryOf": [
                "Place"
            ]
        }
    ]
}

References