Difference between revisions of "Template:Validate and render identifier URI"
From TDWG Terms Wiki
m (added return value=URI and page) |
m (attempt to fix ending #-URIs) |
||
(11 intermediate revisions by the same user not shown) | |||
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}} | + | |
}}<!-- | }}<!-- | ||
check URI definitions: multiple or single once | check URI definitions: multiple or single once | ||
− | + | ||
-->{{#if: {{#pos: {{#var: namespaceURIpageList}}|,}} <!-- | -->{{#if: {{#pos: {{#var: namespaceURIpageList}}|,}} <!-- | ||
then multiple ns URI: ERROR message | then multiple ns URI: ERROR message | ||
Line 17: | Line 16: | ||
| toggle position=left | | toggle position=left | ||
| content=Namespace URIs are defined multiple times on:<ul> | | content=Namespace URIs are defined multiple times on:<ul> | ||
− | <li> | + | <li>{{#var: namespaceURIpageList}}</li>{{ |
#if: {{#var: importNamespaceUri}} | <li>SMW-import-page [[MediaWiki:Smw import {{{namespace prefix|}}}]] ({{#var: importNamespaceUri}}), e.g. for RDF export</li> | #if: {{#var: importNamespaceUri}} | <li>SMW-import-page [[MediaWiki:Smw import {{{namespace prefix|}}}]] ({{#var: importNamespaceUri}}), e.g. for RDF export</li> | ||
}}</ul> | }}</ul> | ||
Line 25: | Line 24: | ||
two (import + defined) / just the defined / just the import / none | two (import + defined) / just the defined / just the import / none | ||
-->|{{#switch: <!-- | -->|{{#switch: <!-- | ||
− | return switch string for cases | + | return switch string for cases |
− | -->{{#if: {{#var: importNamespaceUri}}|importURI}}<!-- | + | -->{{#vardefineecho: caseOfNamespace |<!-- |
− | + | -->{{#if: {{#var: importNamespaceUri}}|importURI}}<!-- | |
− | + | -->{{#if: {{#var: namespaceURIpageList}}<!-- | |
− | + | 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: {{#replace:<!-- bug fix cutted # on uri ending -->{{#var: namespaceURIpageList}}|#)|)}} | {{#replace:<!-- bug fix cutted # on uri ending -->({{#var: importNamespaceUri}})|#)|)}} }} > -1<!-- | |
− | -->|{{#if: {{#var: importNamespaceUri}} <!-- | + | then-->|_is_definedURI<!-- |
− | + | else-->|{{#if: {{#var: importNamespaceUri}} <!-- | |
− | + | -->|_conflicts_with_definedURI<!-- | |
− | + | no importURI just a definedURI | |
− | + | -->|definedURI}} | |
− | + | }}<!-- | |
− | + | -->|<!-- | |
− | -->}} | + | no defined URI |
− | |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|}}}]]) |
|uri={{#var: importNamespaceUri}}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} | |uri={{#var: importNamespaceUri}}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} | ||
− | }}<nowiki></nowiki> {{{info message|}}}{{Warning about conflict of concept URI with SMW import and Concept or Collection | + | }}<nowiki></nowiki> {{{info message|}}}<div style="display:none;" class="debug-template-Validate-and-render-identifier-URI">importURI: {{lc: {{{return value|}}}}}</div>{{Warning about conflict of concept URI with SMW import and Concept or Collection |
|import namespace URI={{#var: importNamespaceUri}} | |import namespace URI={{#var: importNamespaceUri}} | ||
|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= {{#var: importNamespaceUri}}{{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{# | + | |uri and page= <!-- TODO: check if neccessary → {{#var: importNamespaceUri}} --> {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{#rpos:{{#var: namespaceURIpageList}} | ( }} + 1 }} | -1 }}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} ({{ |
− | #sub: {{#var: namespaceURIpageList}} | + | #sub: {{#var: namespaceURIpageList}} |
− | | 0 | {{#expr: {{#pos: {{#var: namespaceURIpageList}} | ] }} + {{#len: ]] }} }} | + | | 0 | {{#expr: {{#pos: {{#var: namespaceURIpageList}} | ] }} + {{#len: ]] }} }} |
}}, <!-- | }}, <!-- | ||
-->[[MediaWiki:Smw import {{{namespace prefix|}}}]]) | -->[[MediaWiki:Smw import {{{namespace prefix|}}}]]) | ||
|uri={{#var: importNamespaceUri}}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} | |uri={{#var: importNamespaceUri}}{{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}} | ||
}}<nowiki></nowiki> {{{info message|}}} | }}<nowiki></nowiki> {{{info message|}}} | ||
− | |importURI_conflicts_with_definedURI={{Warning about conflict of concept URI with SMW import and Concept or Collection | + | |importURI_conflicts_with_definedURI=<div style="display:none;" class="debug-template-Validate-and-render-identifier-URI">importURI_conflicts_with_definedURI: {{lc: {{{return value|}}}}}</div>{{Warning about conflict of concept URI with SMW import and Concept or Collection |
|import namespace URI={{#var: importNamespaceUri}} | |import namespace URI={{#var: importNamespaceUri}} | ||
|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: {{# | + | |uri and page= {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{#rpos:{{#var: namespaceURIpageList}} | ( }} + 1 }} | -1 }} ({{ |
− | #sub: {{#var: namespaceURIpageList}} | + | #sub: {{#var: namespaceURIpageList}} |
− | | 0 | {{#expr: {{#pos: {{#var: namespaceURIpageList}} | ] }} + {{#len: ]] }} }} | + | | 0 | {{#expr: {{#pos: {{#var: namespaceURIpageList}} | ] }} + {{#len: ]] }} }} |
}}) | }}) | ||
− | |uri=<!-- URI from e.g. "[[:Audubon Core|Audubon Core]] (http://rs.tdwg.org/ac/terms/)" | + | |uri=<!-- URI from e.g. "[[:Audubon Core|Audubon Core]] (http://rs.tdwg.org/ac/terms/)" |
− | -->{{#replace: {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{# | + | -->{{#replace: {{#sub: {{#var: namespaceURIpageList}} | {{#expr: {{#rpos:{{#var: namespaceURIpageList}} | ( }} + 1 }} | -1 }} | ) | {{#explode: {{{concept page|{{PAGENAME}}}}}|:|1}}) }} |
− | }}{{Warning about conflict of concept URI with SMW import and Concept or Collection | + | }}<div style="display:none;" class="debug-template-Validate-and-render-identifier-URI">definedURI: {{lc: {{{return value|}}}}}</div>{{Warning about conflict of concept URI with SMW import and Concept or Collection |
|import namespace URI={{#var: importNamespaceUri}} | |import namespace URI={{#var: importNamespaceUri}} | ||
|concept namespace prefix={{{namespace prefix|}}} | |concept namespace prefix={{{namespace prefix|}}} | ||
}} | }} | ||
− | |#default={{#vardefine: hasConflict | 1 }} Warning: no namespace URI defined yet [[File:Warning_icon.svg|x10px|link=]]<nowiki></nowiki> {{{info message|}}} | + | |#default={{#vardefine: hasConflict | 1 }}<div class="debug" style="display:none;">{{#var: caseOfNamespace}}</div> Warning: no namespace URI defined yet [[File:Warning_icon.svg|x10px|link=]]<nowiki></nowiki> {{{info message|}}} |
}} | }} | ||
}}{{ | }}{{ | ||
− | #if: {{#var: hasConflict}} | {{#switch: {{lc: {{{set management category|}}}}} | no | 0 | none|false=| #default=[[Category: | + | #if: {{#var: hasConflict}} | {{#switch: {{lc: {{{set management category|}}}}} | no | 0 | none|false=| #default=[[Category:Internal - URI conflict]] }} |
}}<!-- | }}<!-- | ||
Line 85: | 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><!-- | ||
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 == | ||
− | + | 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> | ||
− | Sets management category: [[:Category: | + | 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: <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