Difference between revisions of "Template:Validate and render identifier URI"
From TDWG Terms Wiki
m (simple namespaceURIpageList not split on comma) |
m (attempt to fix ending #-URIs) |
||
Line 3: | Line 3: | ||
-->{{#vardefine: importNamespaceUri | {{Namespace prefix to imported namespace URI | {{{namespace prefix|}}} }} }}<!-- | -->{{#vardefine: importNamespaceUri | {{Namespace prefix to imported namespace URI | {{{namespace prefix|}}} }} }}<!-- | ||
namespaceURIpageList e.g. "[[:Audubon Core|Audubon Core]] (http://rs.tdwg.org/ac/terms/)" | namespaceURIpageList e.g. "[[:Audubon Core|Audubon Core]] (http://rs.tdwg.org/ac/terms/)" | ||
− | -->{{#vardefine: namespaceURIpageList | {{#ask: | + | -->{{#vardefine: namespaceURIpageList | {{#ask: [[vann:preferredNamespacePrefix::{{{namespace prefix|}}}]] |
− | + | | ?vann:preferredNamespaceUri#= | format=list | link=none}} | |
− | | ?vann:preferredNamespaceUri#= | format=list}} | + | |
}}<!-- | }}<!-- | ||
Line 29: | Line 28: | ||
-->{{#if: {{#var: importNamespaceUri}}|importURI}}<!-- | -->{{#if: {{#var: importNamespaceUri}}|importURI}}<!-- | ||
-->{{#if: {{#var: namespaceURIpageList}}<!-- | -->{{#if: {{#var: namespaceURIpageList}}<!-- | ||
− | check e.g. "(http:// | + | check e.g. "Simple Knowledge Organization System (http://www.w3.org/2004/02/skos/core) | (http://www.w3.org/2004/02/skos/core#)" |
− | -->|{{#ifexpr: {{#rpos: {{#var: namespaceURIpageList}} | ({{#var: importNamespaceUri}}) }} > -1<!-- | + | -->|{{#ifexpr: {{#rpos: {{#replace:<!-- bug fix cutted # on uri ending -->{{#var: namespaceURIpageList}}|#)|)}} | {{#replace:<!-- bug fix cutted # on uri ending -->({{#var: importNamespaceUri}})|#)|)}} }} > -1<!-- |
then-->|_is_definedURI<!-- | then-->|_is_definedURI<!-- | ||
else-->|{{#if: {{#var: importNamespaceUri}} <!-- | else-->|{{#if: {{#var: importNamespaceUri}} <!-- | ||
Line 41: | Line 40: | ||
-->}}<!-- | -->}}<!-- | ||
-->}} | -->}} | ||
− | |importURI = {{#switch: {{lc: {{{return value|}}}}} | + | |importURI = {{ |
+ | #switch: {{lc: {{{return value|}}}}} | ||
|page and uri= [[MediaWiki:Smw import {{{namespace prefix|}}}]] ({{#var: importNamespaceUri}}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}}) | |page and uri= [[MediaWiki:Smw import {{{namespace prefix|}}}]] ({{#var: importNamespaceUri}}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}}) | ||
|uri and page= {{#var: importNamespaceUri}} {{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} ([[MediaWiki:Smw import {{{namespace prefix|}}}]]) | |uri and page= {{#var: importNamespaceUri}} {{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} ([[MediaWiki:Smw import {{{namespace prefix|}}}]]) | ||
Line 49: | Line 49: | ||
|concept namespace prefix={{{namespace prefix|}}} | |concept namespace prefix={{{namespace prefix|}}} | ||
}}{{#vardefine: hasConflict | 1 }} | }}{{#vardefine: hasConflict | 1 }} | ||
− | |importURI_is_definedURI={{#switch: {{lc: {{{return value|}}}}} | + | |importURI_is_definedURI={{ |
+ | #switch: {{lc: {{{return value|}}}}} | ||
|page and uri= {{#replace: {{#var: namespaceURIpageList}} | ) | {{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}}) }} | |page and uri= {{#replace: {{#var: namespaceURIpageList}} | ) | {{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}}) }} | ||
|uri and page= <!-- TODO: check if neccessary → {{#var: importNamespaceUri}} --> {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{#rpos:{{#var: namespaceURIpageList}} | ( }} + 1 }} | -1 }}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} ({{ | |uri and page= <!-- TODO: check if neccessary → {{#var: importNamespaceUri}} --> {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{#rpos:{{#var: namespaceURIpageList}} | ( }} + 1 }} | -1 }}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} ({{ | ||
Line 62: | Line 63: | ||
|concept namespace prefix={{{namespace prefix|}}} | |concept namespace prefix={{{namespace prefix|}}} | ||
}}{{#vardefine: hasConflict | 1 }} | }}{{#vardefine: hasConflict | 1 }} | ||
− | |definedURI={{#switch: {{lc: {{{return value|}}}}} | + | |definedURI={{ |
+ | #switch: {{lc: {{{return value|}}}}} | ||
|page and uri= {{#replace: {{#var: namespaceURIpageList}} | ) | {{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}}) }} | |page and uri= {{#replace: {{#var: namespaceURIpageList}} | ) | {{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}}) }} | ||
|uri and page= {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{#rpos:{{#var: namespaceURIpageList}} | ( }} + 1 }} | -1 }} ({{ | |uri and page= {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{#rpos:{{#var: namespaceURIpageList}} | ( }} + 1 }} | -1 }} ({{ | ||
Line 87: | Line 89: | ||
|text=This template checks for namespace URIs and returns it optionally. In case of multiple definitions or conflicting URIs it will print a warning message for this This template has the following parameter (mandatory is '''bold'''), use it in the format: | |text=This template checks for namespace URIs and returns it optionally. In case of multiple definitions or conflicting URIs it will print a warning message for this This template has the following parameter (mandatory is '''bold'''), use it in the format: | ||
<div class="no-pre-border no-pre-margin no-pre-padding" style="margin-left:1.5em;"> | <div class="no-pre-border no-pre-margin no-pre-padding" style="margin-left:1.5em;"> | ||
− | <nowiki>{{</nowiki> | + | <nowiki>{{</nowiki>Validate and render identifier URI |
− | {{!}}'''namespace prefix='''<!-- e.g. biorel --> | + | {{!}}'''namespace prefix='''<span style="color:gray;"><!-- e.g. biorel --></span> |
− | {{!}}concept page=<!-- optional (default is <nowiki>{{PAGENAME}}</nowiki>) --> | + | {{!}}concept page=<span style="color:gray;"><!-- optional (default is <nowiki>{{PAGENAME}}</nowiki>) --></span> |
− | {{!}}set management category=<!-- optional: value may be any string, e.g. "true", "1" ("0", "no", "false" is false) --> | + | {{!}}set management category=<span style="color:gray;"><!-- optional: value may be any string, e.g. |
− | {{!}}return value=<!-- optional: "page and URI", "URI and page" or "URI" (default return: void or a collapsible warning message box) --> | + | "true", "1" ("0", "no", "false" is false) --></span> |
− | {{!}}info message=<!-- optional: message that appears after URI but before any warnings, e.g. for forms with <nowiki>{{#info: message=text}}</nowiki> --> | + | {{!}}return value=<span style="color:gray;"><!-- optional: |
− | + | "page and URI", | |
+ | "URI and page" or | ||
+ | "URI" (default return: void or a collapsible warning message box) --></span> | ||
+ | {{!}}info message=<span style="color:gray;"><!-- optional: message that appears after URI but before any warnings, e.g. for forms with <nowiki>{{#info: message=text}}</nowiki> --></span> | ||
+ | <nowiki>}}</nowiki> | ||
+ | </div> | ||
}} | }} | ||
}}</includeonly><noinclude><!-- | }}</includeonly><noinclude><!-- | ||
Line 99: | Line 106: | ||
template documentation itself | template documentation itself | ||
− | --> | + | --> |
− | + | This template checks for namespace URIs and returns them optionally. In case of multiple definitions or conflicting URIs it will print a warning message. This template has the following parameter (mandatory is '''bold'''), use it in the format: | |
<div class="no-pre-border no-pre-margin no-pre-padding" style="margin-left:1.5em;"> | <div class="no-pre-border no-pre-margin no-pre-padding" style="margin-left:1.5em;"> | ||
<nowiki>{{</nowiki>{{#titleparts: {{PAGENAME}} | 1 }} | <nowiki>{{</nowiki>{{#titleparts: {{PAGENAME}} | 1 }} | ||
− | {{!}}'''namespace prefix='''<!-- e.g. biorel --> | + | {{!}}'''namespace prefix='''<span style="color:gray;"><!-- e.g. biorel --></span> |
− | {{!}}concept page=<!-- optional (default is <nowiki>{{PAGENAME}}</nowiki>) --> | + | {{!}}concept page=<span style="color:gray;"><!-- optional (default is <nowiki>{{PAGENAME}}</nowiki>) --></span> |
− | {{!}}set management category=<!-- optional: value may be any string, e.g. "true", "1" ("0", "no", "false" is false) --> | + | {{!}}set management category=<span style="color:gray;"><!-- optional: value may be any string, e.g. |
− | {{!}}return value=<!-- optional: "page and URI", "URI and page" or "URI" (default return: void or a collapsible warning message box) --> | + | "true", "1" ("0", "no", "false" is false) --></span> |
− | {{!}}info message=<!-- optional: message that appears after URI but before any warnings, e.g. for forms with <nowiki>{{#info: message=text}}</nowiki> --> | + | {{!}}return value=<span style="color:gray;"><!-- optional: |
− | + | "page and URI", | |
− | + | "URI and page" or | |
+ | "URI" (default return: void or a collapsible warning message box) --></span> | ||
+ | {{!}}info message=<span style="color:gray;"><!-- optional: message that appears after URI but before any warnings, e.g. for forms with <nowiki>{{#info: message=text}}</nowiki> --></span> | ||
+ | <nowiki>}}</nowiki> | ||
+ | </div> | ||
+ | |||
== Technical documentation == | == Technical documentation == | ||
− | Dependent on: [[Template:Warning about conflict of concept URI with SMW import and Concept or Collection]] | + | Note that #-ending URIs, like http://www.w3.org/2009/08/skos-reference/skos.html#, are cut off of the ending #, hence this templates eliminates ending #-URIs when testing. SemanticMediaWiki would show a <code>vann:preferredNamespaceUri::http://www.w3.org/2004/02/skos/core#</code> cut to |
+ | <syntaxhighlight lang="xml"><vann:preferredNamespaceUri rdf:resource="http://www.w3.org/2004/02/skos/core"/></syntaxhighlight> | ||
+ | … and not as trailing # | ||
+ | <syntaxhighlight lang="xml" style="text-decoration: line-through;"><vann:preferredNamespaceUri rdf:resource="http://www.w3.org/2004/02/skos/core#"/></syntaxhighlight> | ||
+ | |||
+ | Dependent on: | ||
+ | * [[Template:Warning about conflict of concept URI with SMW import and Concept or Collection]] | ||
+ | * [[template: TemplateError]] | ||
+ | * [[template: Hidden]] | ||
Sets management category: [[:Category: Internal - URI conflict]] (suppressed by parameter "set management category=no") | Sets management category: [[:Category: Internal - URI conflict]] (suppressed by parameter "set management category=no") | ||
Uses variables: <code>hasConflict</code>, <code>importNamespaceUri</code>, <code>namespaceURIpageList</code> | Uses variables: <code>hasConflict</code>, <code>importNamespaceUri</code>, <code>namespaceURIpageList</code> | ||
+ | |||
+ | |||
[[Category: Helper tool for ontologies]]</noinclude> | [[Category: Helper tool for ontologies]]</noinclude> |
Latest revision as of 23:39, 7 September 2016
This template checks for namespace URIs and returns them optionally. In case of multiple definitions or conflicting URIs it will print a warning message. This template has the following parameter (mandatory is bold), use it in the format:
{{Validate and render identifier URI |namespace prefix=<!-- e.g. biorel --> |concept page=<!-- optional (default is {{PAGENAME}}) --> |set management category=<!-- optional: value may be any string, e.g. "true", "1" ("0", "no", "false" is false) --> |return value=<!-- optional: "page and URI", "URI and page" or "URI" (default return: void or a collapsible warning message box) --> |info message=<!-- optional: message that appears after URI but before any warnings, e.g. for forms with {{#info: message=text}} --> }}
Technical documentation
Note that #-ending URIs, like http://www.w3.org/2009/08/skos-reference/skos.html#, are cut off of the ending #, hence this templates eliminates ending #-URIs when testing. SemanticMediaWiki would show a vann:preferredNamespaceUri::http://www.w3.org/2004/02/skos/core#
cut to
<vann:preferredNamespaceUri rdf:resource="http://www.w3.org/2004/02/skos/core"/>
… and not as trailing #
<vann:preferredNamespaceUri rdf:resource="http://www.w3.org/2004/02/skos/core#"/>
Dependent on:
- Template:Warning about conflict of concept URI with SMW import and Concept or Collection
- template: TemplateError
- template: Hidden
Sets management category: Category: Internal - URI conflict (suppressed by parameter "set management category=no")
Uses variables: hasConflict
, importNamespaceUri
, namespaceURIpageList