Help:Recommendation for setting Data Types in Semantic MediaWiki

From TDWG Terms Wiki
Jump to: navigation, search

This is a DRAFT version.

To help you choosing the right data type for a property page the following brief overview may help you. In the end reasonable RDF should be given.

      What datatype: Page or URI/URL?
             Values are …
 ┌ … reused data ─←┴→─ … completely ┐
 │ (a Wiki page       external data │
 │  exists)           (no Wiki page)│
 ↓                                  ↓
use                                use
Page                              URL or 
                                  Annotation URI

Data Types

The difference between data types Page, URL and Annotation URI is the generated RDF, in particular the attribute "rdf:resource" of the property:

  • type Page generates rdf:resource="http://terms.gbif.org/wiki/Special:URIResolver/Value-is-a-Page" (e.g. based on "[[my-property::Value-is-a-Page]]") or rdf:resource="http://correct/external/URI/of/imported-concept" (e.g. based on [[my-property::Property:imported-concept]])
  • type URL and Annotation URI generates (e.g. based on "[[my-property::http://any-full-URL]]") rdf:resource="http://any-full-URL"

Page

Data type Page

  • is default when nothing is set (no [[Has type::SMW-datatype]] on a property page)
  • can be an imported vocabulary concept (using the syntax [[Imported from::namespace:importedterm]]) and resolves finally to the external URI
  • recommended when doing import and using it locally as a page
  • for imported concepts save it as [[my-property::Property:ns:concept-term]] not as [[my-property::ns:concept-term]]
Technical notes …

RDF-Export of a [[Has type::Page]] becomes, e.g. for SKOS import from page MediaWiki:Smw import skos:

<!DOCTYPE rdf:RDF>
<rdf:RDF xmlns:skos="http://www.w3.org/2004/02/skos/core#">
<!--                 defined on MediaWiki:Smw import skos
                     └──────┬───────────────────────────┘
  ┌─────────────────────────┘
  │   -->
<skos:inScheme rdf:resource="http://terms.gbif.org/wiki/Special:URIResolver/Saved-Value-is-a-Page"/>
</rdf:RDF>


URL

Data type URL

  • only for full URLs/URIs. Problems arise when mixing local Wiki page references with external URI references. Simple saving the local wiki page name will not only prevent proper linking functionality, but also cause wrong values in RDF-Export. Local page references must therefore always be expanded to a full URL in the Wiki (this can be done, e.g. in Wiki templates using the parser function [[my-property::{{fullurl: local-page-name}}]])
    Technical notes (RDF export) …

    QUESTION: Will [[my-property::{{fullurl: Property:local-page-name}}]], in RDF-Export, be rewritten using the import definitions?

    ANSWER: «my-property» yes but not the full URL of the property page. [[my-property::https://terms.tdwg.org/wiki/Property:local-page-name]] becomes an <my-property rdf:resource="https://terms.tdwg.org/wiki/Property:local-page-name"> and this points to the HTML page. Only an additional step of Special:ExportRDF (https://terms.tdwg.org/wiki/Special:ExportRDF/Property:local-page-name) would resolve it. It might work to save the URL value together with Special:ExportRDF-URL and parserfunction fullurl (Wiki syntax of [[my-property::https://terms.tdwg.org/wiki/Special:ExportRDF/Property:local-page-name]] would generate a RDF of <my-property rdf:resource="https://terms.tdwg.org/wiki/Special:ExportRDF/Property:local-page-name">)

    <!DOCTYPE rdf:RDF>
    <!-- "myns" = "my name space" -->
    <rdf:RDF xmlns:myns="http://www.blah.org/core#">
    <!--                 defined on MediaWiki:Smw import myns
                         └──────┬────────────────┘
      ┌─────────────────────────┘
      │   -->
    <myns:my-property rdf:resource="http://any-full-URL"/>
    </rdf:RDF>
    
  • recommended when it is on type URL, URI, URN
  • to get URLs of local page names make use in template programming of {{Complete pagename to fullurl | PAGENAME or URL}}
  • to get correct URIs of imported concepts, e.g. of “dc:creator”, use {{Concept to imported URI|dc:creator (must be a property page)}}
    Example …
    To get the correct URI of an imported concept dc:creator use:
    <!-- will print the URI -->
    [[my-URI-property::{{Concept to imported URI|dc:creator}}]]
    <!-- silent annotation -->
    [[my-URI-property::{{Concept to imported URI|dc:creator}}| ]]
    {{#set: my-URI-property={{Concept to imported URI|dc:creator}}}}
    

    Note: the SMW import page must exist (see Help import a vocabulary concept)

  • in SMW Version 1.7 an error is reported if the URL contains a # character (seems a bug, SMW 1.8 does not show it)

Annotation URI

Data type Annotation URI

  • is a variant of datatype URL. It is used in cases where a URL property needs to be exported as an owl:AnnotationProperty which is the case almost exclusively for imported properties.
  • only for full URLs/URIs
  • to get URLs of local page names make use in template programming of {{Complete pagename to fullurl | PAGENAME or URL}}
  • to get correct URIs of imported concepts, e.g. of “dc:creator”, use {{Concept to imported URI|dc:creator (must be a property page)}}
    Example …
    To get the correct URI of an imported concept dc:creator use:
    <!-- will print the URI -->
    [[my-URI-property::{{Concept to imported URI|dc:creator}}]]
    <!-- silent annotation -->
    [[my-URI-property::{{Concept to imported URI|dc:creator}}| ]]
    {{#set: my-URI-property={{Concept to imported URI|dc:creator}}}}
    

    Note: the SMW import page must exist (see Help import a vocabulary concept)

  • TODO recommended when …
  • in SMW Version 1.7 an error is reported if the URL contains a # character (seems a bug, SMW 1.8 does not show it)

String

  • this is DEPRECATED since SemanticMediaWiki 1.8+ and “Text” will be used internally
  • is limited to 255 characters
  • can be searched, filtered, sorted using #ask parser function

Text

  • holds text of arbitrary length
  • can be searched partially: if text is ≤ 72 characters it's all searchable, if text is > 72 characters then only the first 40 characters can be searched