Difference between revisions of "Talk:Natural Collections Description"
From TDWG Terms Wiki
m (+section Form links for creation of NCD concepts) |
m (→Form links for creation of NCD concepts: +awk script) |
||
Line 202: | Line 202: | ||
== Form links for creation of NCD concepts == | == Form links for creation of NCD concepts == | ||
+ | |||
+ | === Generation script (Linux) === | ||
+ | {{Hidden | ||
+ | |contentstyle=border-left: 2px solid #ccc;padding:0ex 0.5em; | ||
+ | |toggle position=left | ||
+ | |header=awk script for generating wikitext with formlinks… | ||
+ | |content=<syntaxhighlight lang="awk"> | ||
+ | #!/bin/awk | ||
+ | # BEGIN {} # block executed before processing | ||
+ | # END {} # block executed after processing | ||
+ | # FS input field separator (default: " ") | ||
+ | # RS record separator (default: newline) | ||
+ | |||
+ | # TODO | ||
+ | # 2012-11-27 11:04:50 check instances of Classes if they are assigned to the right concept type or/and instance-relation (skos:Collection or skos:inScheme or vann:termGroup etc) | ||
+ | |||
+ | ########################################## | ||
+ | # This file converts NCD Collection.rdf | ||
+ | # into SMW {{#formlink}}. See also in the | ||
+ | # BEGIN {…} section. An adapted version of | ||
+ | # this file may also be applicable to the | ||
+ | # other RDF files in NCD scheme | ||
+ | #---- Usage: save this file as NCD-Collection.awk and execute: | ||
+ | # gawk -f NCD-Collection.awk Collection.rdf > Collection.wikitext | ||
+ | ########################################## | ||
+ | |||
+ | |||
+ | #### programm developer checks ########### | ||
+ | # Check for all elements within range of | ||
+ | # e.g. owl:DatatypeProperty to owl:DatatypeProperty | ||
+ | # | ||
+ | # sed --quiet "/owl:DatatypeProperty/,/owl:DatatypeProperty/{ s@\t*@@g; s@[ >].*@@g; p;}" "NCDTest-Collection.rdf" | sort --unique | ||
+ | # sed --quiet "/owl:ObjectProperty/,/owl:ObjectProperty/{ s@\t*@@g; s@[ >].*@@g; p;}" "NCDTest-Collection.rdf" | sort --unique | ||
+ | # sed --quiet "/owl:Class/,/owl:Class/{ s@\t*@@g; s@[ >].*@@g; p;}" "NCDTest-Collection.rdf" | sort --unique | ||
+ | # awk '$0~/<[A-Za-z]+ /{ print $0}' "NCDTest-Collection.rdf" | sed --quiet "s@.*\(<[A-Za-z]\+\).*@\1@g;p" | sort --unique | ||
+ | #--- check elements for instances of classes: get all instances in $filename and list all elements in it (just a programm developer check) | ||
+ | #--- just display execution command: | ||
+ | # filename="NCDTest-Collection.rdf";awk '$0~/<[A-Za-z]+ /{ print $0}' "$filename" | sed --quiet "s@.*<\([A-Za-z]\+\).*@\1@g;p" | sort --unique | sed "s@\(.*\)@sed --quiet \"/<\1/,/<\\\/\1/{ s\@\\\t*\@\@g; s\@[ >].*\@\@g; p;}\" \"$filename\" | sort --unique@" | ||
+ | ## execute command: | ||
+ | # filename="NCDTest-Collection.rdf";awk '$0~/<[A-Za-z]+ /{ print $0}' "$filename" | sed --quiet "s@.*<\([A-Za-z]\+\).*@\1@g;p" | sort --unique | sed "s@\(.*\)@sed --quiet \"/<\1/,/<\\\/\1/{ s\@\\\t*\@\@g; s\@[ >].*\@\@g; p;}\" \"$filename\" | sort --unique@" | sh | sort --unique | ||
+ | |||
+ | # perl -pne 'BEGIN {undef $/} s/ │<!--\n\n-->\n\n<!--\n--> +/\n* /gm' NCDTest-Collection.mwt > NCDTest-Collection-export.mwt | ||
+ | ########################################## | ||
+ | # GLOBAL VARIABLES start with glob_… | ||
+ | ########################################## | ||
+ | |||
+ | |||
+ | BEGIN { | ||
+ | FS ="\"" # field separator to quotation mark " (default is " ") | ||
+ | glob_issued="2007/03/05" | ||
+ | glob_modified="2007/09/24" | ||
+ | glob_namespacePrefix="ncd.coll" | ||
+ | glob_namespaceUri="http://rs.tdwg.org/ontology/voc/Collection#" | ||
+ | glob_namespace_isDefinedBy="http://rs.tdwg.org/ontology/voc/Collection" | ||
+ | glob_namespaceUriEncoded="http://rs.tdwg.org/ontology/voc/Collection%23" | ||
+ | }# BEGIN | ||
+ | |||
+ | ####### functions start ################## | ||
+ | function ltrim(s) { sub(/^[ \t]+/, "", s); return s } | ||
+ | function rtrim(s) { sub(/[ \t]+$/, "", s); return s } | ||
+ | function trim(s) { return rtrim(ltrim(s)); } | ||
+ | |||
+ | function get_rdfsLabel() { | ||
+ | #<rdfs:label>Collection Identifier</rdfs:label> | ||
+ | return trim(gensub(/.*<(rdfs:label)>(.+)<\/rdfs:label>.*/, "\\2", "g", $0)) | ||
+ | }# get_rdfsLabel | ||
+ | |||
+ | function get_attributeValueUrlEncoded() { | ||
+ | # must be FS="\"" !! | ||
+ | #<rdfs:domain rdf:resource="#Collection"/> | ||
+ | firstAttributeValue=$2 | ||
+ | if (firstAttributeValue~/^#/) { | ||
+ | firstAttributeValue=gensub(/^#/, glob_namespaceUriEncoded, "g", firstAttributeValue) | ||
+ | } else { | ||
+ | firstAttributeValue=gensub(/#/, "%23", "g", firstAttributeValue) | ||
+ | } | ||
+ | return firstAttributeValue | ||
+ | }# get_attributeValueUrlEncoded | ||
+ | |||
+ | function get_xmlDataElement (xpathQuery) { | ||
+ | # use xml_grep and sed to get trimmed single line values | ||
+ | # "xml_grep xml_grep --text_only --cond \"" xpathQuery "\" " FILENAME " | sed 's@^ *@@;:a;N;$!ba;s/\\n\\t\\+//g;'" | getline output | ||
+ | # has less features, e.g. get only the attribute | ||
+ | "xpath " FILENAME " \"" xpathQuery "\" 2>/dev/null | sed ':a;N;$!ba; s@\\n@@g; s@[ \\t]\\+@ @g;'" | getline output | ||
+ | # 2>/dev/null removes the xpath's script insertions like "-- NODE --" | ||
+ | return output | ||
+ | } | ||
+ | |||
+ | function get_conceptType(typeUrl){ | ||
+ | |||
+ | switch (tolower(gensub(/.*#/,"", "g", typeUrl))) { | ||
+ | case "datatypeproperty": | ||
+ | type="data type" | ||
+ | case "class": | ||
+ | type="class" | ||
+ | case "value": | ||
+ | type="value" | ||
+ | default: | ||
+ | type="property" | ||
+ | } | ||
+ | return type | ||
+ | } | ||
+ | function emptyGlobalVariables() { | ||
+ | glob_conceptDefinition = ""; | ||
+ | glob_conceptDomain = ""; | ||
+ | glob_conceptID = ""; | ||
+ | glob_conceptNotes = ""; | ||
+ | glob_conceptRange = ""; | ||
+ | glob_conceptType = ""; | ||
+ | glob_rdfs_isDefinedBy = ""; | ||
+ | glob_rdfs_Label = ""; | ||
+ | glob_rdfs_subClassOf = ""; | ||
+ | glob_rdfs_subPropertyOf = ""; | ||
+ | glob_skosCollection = ""; | ||
+ | }# emptyGlobalVariables | ||
+ | |||
+ | function create_formLink(conceptID, kindOfConceptComment, startNewOutputSection) { | ||
+ | # use global variables to generate the form link | ||
+ | |||
+ | #### start #### | ||
+ | print ((startNewOutputSection == 0) ? "--> " : "-->\n*" ) \ | ||
+ | " {{#formlink: form=Concept\n | link text = " \ | ||
+ | glob_namespacePrefix ":" conceptID " [[File:Pencil.png|link=]]\n | target = " glob_namespacePrefix ":" conceptID "\n | query string =<!-- " kindOfConceptComment | ||
+ | if (glob_rdfs_Label) print "-->Concept[label]=" glob_rdfs_Label "<!--" | ||
+ | # append all other fields | ||
+ | if (glob_conceptDefinition) print "-->&Concept[definition]=" trim(glob_conceptDefinition) "<!--" | ||
+ | if (glob_conceptNotes) print "-->&Concept[notes]=" trim(glob_conceptNotes) "<!--" | ||
+ | if (glob_conceptType) print "-->&Concept[concept type]=" trim(glob_conceptType) "<!--" | ||
+ | if (glob_modified) print "-->&Concept[modified]=" gensub("/", "%2F", "g", glob_modified) "<!--" | ||
+ | if (glob_issued) print "-->&Concept[issued]=" gensub("/", "%2F", "g", glob_issued) "<!--" | ||
+ | if (glob_rdfs_isDefinedBy) | ||
+ | print "-->&Concept[is defined by]=<nowiki>" trim(glob_rdfs_isDefinedBy) "</nowiki><!--" | ||
+ | else | ||
+ | print "-->&Concept[is defined by]=<nowiki>" glob_namespace_isDefinedBy "</nowiki><!--" | ||
+ | |||
+ | #if (glob_conceptDomain || glob_conceptRange) | ||
+ | print "-->&Concept scheme relation[1][scheme]=Natural Collections Description<!--" | ||
+ | if (glob_conceptDomain) print "-->&Concept scheme relation[1][property domain]=<nowiki>" trim(glob_conceptDomain) "</nowiki><!--" | ||
+ | if (glob_conceptRange) print "-->&Concept scheme relation[1][property range]=<nowiki>" trim(glob_conceptRange) "</nowiki><!--" | ||
+ | if (glob_rdfs_subPropertyOf) print "-->&Concept relation[1][relation]=rdfs: subproperty of<!--" | ||
+ | if (glob_rdfs_subPropertyOf) print "-->&Concept relation[1][uri]=<nowiki>" trim(glob_rdfs_subPropertyOf) "</nowiki><!--" | ||
+ | if (glob_rdfs_subClassOf) print "-->&Concept relation[1][relation]=rdfs: subclass of<!--" | ||
+ | if (glob_rdfs_subClassOf) print "-->&Concept relation[1][uri]=<nowiki>" trim(glob_rdfs_subClassOf) "</nowiki><!--" | ||
+ | if (glob_skosCollection) print "-->&Concept relation[1][relation]=skos: collection<!--" | ||
+ | if (glob_skosCollection) print "-->&Concept relation[1][internal page]=NCD " trim(glob_skosCollection) "<!--" | ||
+ | #### end #### | ||
+ | print "-->}} │<!--" | ||
+ | emptyGlobalVariables() | ||
+ | }# create_formLink | ||
+ | ####### functions end #################### | ||
+ | |||
+ | |||
+ | ########## ObjectProperty ################ | ||
+ | # in the range of <owl:ObjectProperty … </owl:ObjectProperty> do: | ||
+ | /.*<owl:ObjectProperty/,/.*<\/owl:ObjectProperty>/ { | ||
+ | glob_conceptType = "property" | ||
+ | # <rdfs:comment <rdfs:domain <rdfs:isDefinedBy <rdfs:label <rdfs:range <rdfs:subPropertyOf | ||
+ | # get glob_conceptID in <owl:ObjectProperty rdf:ID="collectionId"> | ||
+ | if ($0~/.*<owl:ObjectProperty/) { # print $2 # check data | ||
+ | glob_conceptID=$2 | ||
+ | glob_conceptDefinition = get_xmlDataElement("*/owl:ObjectProperty[@rdf:ID='" glob_conceptID "']/rdfs:comment/text()") | ||
+ | } | ||
+ | else { | ||
+ | if ($0~/<rdfs:label/) { glob_rdfs_Label = get_rdfsLabel() } | ||
+ | if ($0~/.*<rdfs:domain/) { glob_conceptDomain = get_attributeValueUrlEncoded() } | ||
+ | # print "domain: " glob_conceptDomain | ||
+ | if ($0~/.*<rdfs:range/) { glob_conceptRange = get_attributeValueUrlEncoded() } | ||
+ | # print "range: " glob_conceptRange | ||
+ | if ($0~/.*<rdfs:isDefinedBy/) { glob_rdfs_isDefinedBy = get_attributeValueUrlEncoded() } | ||
+ | # print "rdfs:isDefinedBy: " glob_rdfs_isDefinedBy | ||
+ | if ($0~/.*<rdfs:subPropertyOf/) { glob_rdfs_subPropertyOf = get_attributeValueUrlEncoded() } | ||
+ | # print "rdfs:subPropertyOf: " glob_rdfs_subPropertyOf | ||
+ | }# definitions within <owl:ObjectProperty>…</owl:ObjectProperty> | ||
+ | |||
+ | if ($0~/.*<\/owl:ObjectProperty>/) { | ||
+ | print create_formLink(glob_conceptID, "ObjectProperty") | ||
+ | } | ||
+ | }# values in ObjectProperty | ||
+ | |||
+ | ########## DatatypeProperty ############## | ||
+ | # in the range of <owl:DatatypeProperty … </owl:DatatypeProperty> do: | ||
+ | /<owl:DatatypeProperty/,/<\/owl:DatatypeProperty>/ { | ||
+ | glob_conceptType="data type" | ||
+ | # <rdfs:comment <rdfs:domain <rdfs:isDefinedBy <rdfs:label <rdfs:range <rdfs:subPropertyOf | ||
+ | # get glob_conceptID in <owl:DatatypeProperty rdf:ID="collectionId"> | ||
+ | if ($0~/.*<owl:DatatypeProperty/) { # print $2 # check data | ||
+ | glob_conceptID=$2 | ||
+ | glob_conceptDefinition = get_xmlDataElement("*/owl:DatatypeProperty[@rdf:ID='" glob_conceptID "']/rdfs:comment/text()") | ||
+ | # print "rdfs:comment (definition): " glob_conceptDefinition | ||
+ | } | ||
+ | else { | ||
+ | if ($0~/.*<rdfs:label/) { glob_rdfs_Label = get_rdfsLabel() } | ||
+ | # print "rdfs:label: " glob_rdfs_Label | ||
+ | if ($0~/.*<rdfs:domain/) { glob_conceptDomain = get_attributeValueUrlEncoded() } | ||
+ | # print "domain: " glob_conceptDomain | ||
+ | if ($0~/.*<rdfs:range/) { glob_conceptRange = get_attributeValueUrlEncoded() } | ||
+ | if ($0~/.*<rdf:type/) { glob_conceptType = get_conceptType(get_attributeValueUrlEncoded()) } | ||
+ | # print "range: " glob_conceptRange | ||
+ | if ($0~/.*<rdfs:isDefinedBy/) { glob_rdfs_isDefinedBy = get_attributeValueUrlEncoded() } | ||
+ | # print "rdfs:isDefinedBy: " glob_rdfs_isDefinedBy | ||
+ | if ($0~/.*<rdfs:subPropertyOf/) { glob_rdfs_subPropertyOf = get_attributeValueUrlEncoded() } | ||
+ | # print "rdfs:subPropertyOf: " glob_rdfs_subPropertyOf | ||
+ | }# definitions within <owl:DatatypeProperty>…</owl:DatatypeProperty> | ||
+ | |||
+ | if ($0~/.*<\/owl:DatatypeProperty>/) { | ||
+ | #### Create the form link #### | ||
+ | print create_formLink(glob_conceptID, "DatatypeProperty") | ||
+ | } | ||
+ | }# values in DatatypeProperty | ||
+ | |||
+ | |||
+ | ########## owl:Class and its instances #### | ||
+ | # Classes and instances of a particular class | ||
+ | $0~/<owl:Class/ {# Class definition starts | ||
+ | classNameID=$2 | ||
+ | readingOwlClass=classNameID | ||
+ | glob_conceptDefinition = get_xmlDataElement("*/owl:Class[@rdf:ID='" classNameID "']/rdfs:comment/text()") | ||
+ | }# owl:Class | ||
+ | |||
+ | readingOwlClass != "" { | ||
+ | glob_conceptType = "class" | ||
+ | if ($0~/<rdfs:label>/) { glob_rdfs_Label = get_rdfsLabel() } | ||
+ | if ($0~/.*<rdfs:subClassOf/) { glob_rdfs_subClassOf = get_attributeValueUrlEncoded() } | ||
+ | # print "rdfs:subClassOf: " glob_rdfs_subClassOf | ||
+ | if ($0~/.*<rdfs:isDefinedBy/) { glob_rdfs_isDefinedBy = get_attributeValueUrlEncoded() } | ||
+ | # print "rdfs:isDefinedBy: " glob_rdfs_isDefinedBy | ||
+ | if ($0~/.*<rdf:type/) { glob_conceptType = get_conceptType(get_attributeValueUrlEncoded()) } | ||
+ | } | ||
+ | $0~/.*<\/owl:Class>/ {# Class definition closes | ||
+ | readingOwlClass="" | ||
+ | print create_formLink(classNameID, "Class", 1); # separate for output | ||
+ | } | ||
+ | |||
+ | # reading instances of this class | ||
+ | classNameID != "" { | ||
+ | if(index ($0, "<" classNameID ) > 0) {# an instance of the class was found, e.g. <PrimaryGroupingPrincipleTypeTerm …> of <owl:Class rdf:ID="PrimaryGroupingPrincipleTypeTerm"> | ||
+ | glob_conceptType="value" | ||
+ | glob_conceptID=$2 | ||
+ | readingInstanceOfClass=classNameID | ||
+ | }# a class property found | ||
+ | if(readingInstanceOfClass) { | ||
+ | if ($0~/.*<rdfs:label/) glob_rdfs_Label = get_rdfsLabel() # get_xmlDataElement("*/" classNameID "[@rdf:ID='" glob_conceptID "']/rdfs:label/text()") | ||
+ | if ($0~/.*<rdfs:comment/) glob_conceptNotes = get_xmlDataElement("*/" classNameID "[@rdf:ID='" glob_conceptID "']/rdfs:comment/text()") | ||
+ | if ($0~/.*<dc:title/) { } # don't know yet what to do with it | ||
+ | if ($0~/.*<tbase:definition/) glob_conceptDefinition = get_xmlDataElement("*/" classNameID "[@rdf:ID='" glob_conceptID "']/tbase:definition/text()") | ||
+ | if ($0~/.*<rdfs:subClassOf/) { glob_rdfs_subClassOf = get_attributeValueUrlEncoded() } | ||
+ | if ($0~/.*<rdf:type/) { glob_conceptType = get_conceptType(get_attributeValueUrlEncoded()) } | ||
+ | # no glob_rdfs_subPropertyOf but a glob_skosCollection | ||
+ | glob_skosCollection = classNameID | ||
+ | } | ||
+ | if(index ($0, "</" classNameID ">") > 0) {# the | ||
+ | readingInstanceOfClass="" | ||
+ | print create_formLink(glob_conceptID, "Property in class"); | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | }} | ||
+ | |||
=== [http://rs.tdwg.org/ontology/voc/Collection.rdf Collection] === | === [http://rs.tdwg.org/ontology/voc/Collection.rdf Collection] === |
Revision as of 11:13, 27 November 2012
Contents
Preferred Namespaces and URIs
Collection | Preferred namespace | Preferred namespace URI |
Is in svn Ontology.owl |
Comments |
---|---|---|---|---|
Base | tbase |
http://rs.tdwg.org/ontology/Base# | yes | Collection.rdf[1] defines the namespace "tbase" xmlns:tbase="http://rs.tdwg.org/ontology/Base#"; note: it is also defined as ns "base" in CollectionType.rdf[2] → probably mistakenly.
|
Core | tcore | http://rs.tdwg.org/ontology/Core# | yes | Procedure.rdf defines the namespace "tcore" xmlns:tcore="http://rs.tdwg.org/ontology/Core#" |
Collection | ?tco ?tcoll ?ncd-collection |
http://rs.tdwg.org/ontology/voc/Collection# | yes | namespace “ncd-collection” was decided by Gregor Hagedorn, Andreas Plank; following the "t…" naming scheme the briefest namespace is "tco"; tc is already defined by TaxonConcept |
CollectionType | ?tcot ?tcollt ?tcolltype ?ncd-collectiontype |
http://rs.tdwg.org/ontology/voc/CollectionType# | yes | suggested namespace by Andreas Plank; following the "t…" naming scheme "tcot" namespace is the briefest; tct is already defined by OccurrenceStatusTerm |
Common | tcom | http://rs.tdwg.org/ontology/voc/Common# | yes | TaxonConcept.rdf or Institution.rdf (among many others) define namespace "tcom" xmlns:tcom="http://rs.tdwg.org/ontology/voc/Common#"; common to all concepts |
ContactDetails | tcd | http://rs.tdwg.org/ontology/voc/ContactDetails# | yes | namespace "tcd" because ContactDetails.rdf defines xmlns:tcd="http://rs.tdwg.org/ontology/voc/ContactDetails#" |
CyclicityTerm | tct | http://rs.tdwg.org/ontology/voc/CyclicityTerm# | no | seems in development, namespace "tct" because CyclicityTerm.rdf defines xmlns:tdi="http://rs.tdwg.org/ontology/voc/CyclicityTerm#"; conflicts with OccurrenceStatusTerm that probably defines its "tct" namespace mistakenly |
DigitalImage | tdi | http://rs.tdwg.org/ontology/voc/DigitalImage# | yes | namespace "tdi" because DigitalImage.rdf defines xmlns:tdi="http://rs.tdwg.org/ontology/voc/DigitalImage#" |
GeographicRegion | gr | http://rs.tdwg.org/ontology/voc/GeographicRegion# | no | namespace "gr" because GeographicRegion.rdf defines xmlns:gr="http://rs.tdwg.org/ontology/voc/GeographicRegion#" |
Institution | tinst | http://rs.tdwg.org/ontology/voc/Institution# | yes | namespace "tinst" because Institution.rdf defines xmlns:tinst="http://rs.tdwg.org/ontology/voc/Institution#" |
InstitutionType | titype | http://rs.tdwg.org/ontology/voc/InstitutionType# | yes | namespace "titype" because Institution.rdf defines xmlns:titype="http://rs.tdwg.org/ontology/voc/InstitutionType#" |
OccurrenceRecord | tor | http://rs.tdwg.org/ontology/voc/OccurrenceRecord# | no | namespace "tor" because OccurrenceRecord.rdf defines xmlns:tor="http://rs.tdwg.org/ontology/voc/OccurrenceRecord#" |
OccurrenceStatusTerm | tct | http://rs.tdwg.org/ontology/voc/OccurrenceStatusTerm# | yes | namespace "tct" because OccurrenceStatusTerm.rdf defines xmlns:tct="http://rs.tdwg.org/ontology/voc/OccurrenceStatusTerm#", conflicts with CyclicityTerm |
Person | tp | http://rs.tdwg.org/ontology/voc/Person# | yes | namespace "tp" because Person.rdf xmlns:tp="http://rs.tdwg.org/ontology/voc/Person#"; conflicts with taxpub's preferred namespace "tp" |
Procedure | tproc | http://rs.tdwg.org/ontology/voc/Procedure# | yes | Procedure.rdf defines the namespace xmlns:tproc="http://rs.tdwg.org/ontology/voc/Procedure#" |
PublicationCitation | tpub | http://rs.tdwg.org/ontology/voc/PublicationCitation# | yes | PublicationCitation.rdf defines the namespace xmlns:tpub="http://rs.tdwg.org/ontology/voc/PublicationCitation#" |
SpeciesProfileModel | spm | http://rs.tdwg.org/ontology/voc/SpeciesProfileModel# | yes | SpeciesProfileModel.rdf defines the namespace xmlns:spm="http://rs.tdwg.org/ontology/voc/SpeciesProfileModel#" |
SPMInfoItems | spmi | http://rs.tdwg.org/ontology/voc/SPMInfoItems# | no | SPMInfoItems.rdf defines the namespace xmlns:spmi="http://rs.tdwg.org/ontology/voc/SPMInfoItems#"; it's not in the subversion Ontology.owl but listed on TDWG website http://rs.tdwg.org/ontology/voc/ |
Specimen | tsp | http://rs.tdwg.org/ontology/voc/Specimen# | yes | Specimen.rdf defines the namespace xmlns:tsp="http://rs.tdwg.org/ontology/voc/Specimen#" |
TaxonConcept | tc | http://rs.tdwg.org/ontology/voc/TaxonConcept# | yes | TaxonConcept.rdf defines the namespace xmlns:tc="http://rs.tdwg.org/ontology/voc/TaxonConcept#" |
TaxonName | tn | http://rs.tdwg.org/ontology/voc/TaxonName# | yes | TaxonName.rdf defines the namespace xmlns:tn="http://rs.tdwg.org/ontology/voc/TaxonName#" |
TaxonOccurrence | tto | http://rs.tdwg.org/ontology/voc/TaxonOccurrence# | yes | TaxonOccurrence.rdf defines the namespace xmlns:tto="http://rs.tdwg.org/ontology/voc/TaxonOccurrence# |
TaxonOccurrenceInteraction | ?? | http://rs.tdwg.org/ontology/voc/TaxonOccurrenceInteraction# | no | TaxonOccurrenceInteraction.rdf defines no namespace; it is not in the subversion Ontology.owl but listed on TDWG website http://rs.tdwg.org/ontology/voc/ |
TaxonRank | trank | http://rs.tdwg.org/ontology/voc/TaxonRank# | yes | TaxonRank.rdf defines the namespace xmlns:trank="http://rs.tdwg.org/ontology/voc/TaxonRank#" |
Team | tt | http://rs.tdwg.org/ontology/voc/Team# | yes | Team.rdf defines the namespace xmlns:tt="http://rs.tdwg.org/ontology/voc/Team#" |
TermWithSource | ?? | http://rs.tdwg.org/ontology/voc/TermWithSource# | no | TermWithSource.rdf defines the namespace; seems in development (is not listed either on TDWG website http://rs.tdwg.org/ontology/voc/) |
Defined namespaces in NCD
TODO decide for namespace prefixes of Collection, CollectionType, Person, TaxonOccurrenceInteraction, TermWithSource --Andreas Plank 09:58, 20 November 2012 (CET)
- Namespace "base" should be "tbase" --Andreas Plank 12:00, 23 November 2012 (CET)
- Namespace "tct" of OccurrenceStatusTerm in OccurrenceStatusTerm.rdf is probably wrong --Andreas Plank 13:27, 23 November 2012 (CET)
- According to declaration of namespaces we could change all earlier defined namespaces and prefix them with "ncd.". I made a proposal in column "ncd. prefixes" in the table below. For that I removed some "t…" prefixes and kept "t…" prefixes only where I thought it would be necessary --Andreas Plank 13:27, 23 November 2012 (CET)
Form links for creation of NCD concepts
Generation script (Linux)
awk script for generating wikitext with formlinks…
#!/bin/awk
# BEGIN {} # block executed before processing
# END {} # block executed after processing
# FS input field separator (default: " ")
# RS record separator (default: newline)
# TODO
# 2012-11-27 11:04:50 check instances of Classes if they are assigned to the right concept type or/and instance-relation (skos:Collection or skos:inScheme or vann:termGroup etc)
##########################################
# This file converts NCD Collection.rdf
# into SMW {{#formlink}}. See also in the
# BEGIN {…} section. An adapted version of
# this file may also be applicable to the
# other RDF files in NCD scheme
#---- Usage: save this file as NCD-Collection.awk and execute:
# gawk -f NCD-Collection.awk Collection.rdf > Collection.wikitext
##########################################
#### programm developer checks ###########
# Check for all elements within range of
# e.g. owl:DatatypeProperty to owl:DatatypeProperty
#
# sed --quiet "/owl:DatatypeProperty/,/owl:DatatypeProperty/{ s@\t*@@g; s@[ >].*@@g; p;}" "NCDTest-Collection.rdf" | sort --unique
# sed --quiet "/owl:ObjectProperty/,/owl:ObjectProperty/{ s@\t*@@g; s@[ >].*@@g; p;}" "NCDTest-Collection.rdf" | sort --unique
# sed --quiet "/owl:Class/,/owl:Class/{ s@\t*@@g; s@[ >].*@@g; p;}" "NCDTest-Collection.rdf" | sort --unique
# awk '$0~/<[A-Za-z]+ /{ print $0}' "NCDTest-Collection.rdf" | sed --quiet "s@.*\(<[A-Za-z]\+\).*@\1@g;p" | sort --unique
#--- check elements for instances of classes: get all instances in $filename and list all elements in it (just a programm developer check)
#--- just display execution command:
# filename="NCDTest-Collection.rdf";awk '$0~/<[A-Za-z]+ /{ print $0}' "$filename" | sed --quiet "s@.*<\([A-Za-z]\+\).*@\1@g;p" | sort --unique | sed "s@\(.*\)@sed --quiet \"/<\1/,/<\\\/\1/{ s\@\\\t*\@\@g; s\@[ >].*\@\@g; p;}\" \"$filename\" | sort --unique@"
## execute command:
# filename="NCDTest-Collection.rdf";awk '$0~/<[A-Za-z]+ /{ print $0}' "$filename" | sed --quiet "s@.*<\([A-Za-z]\+\).*@\1@g;p" | sort --unique | sed "s@\(.*\)@sed --quiet \"/<\1/,/<\\\/\1/{ s\@\\\t*\@\@g; s\@[ >].*\@\@g; p;}\" \"$filename\" | sort --unique@" | sh | sort --unique
# perl -pne 'BEGIN {undef $/} s/ │<!--\n\n-->\n\n<!--\n--> +/\n* /gm' NCDTest-Collection.mwt > NCDTest-Collection-export.mwt
##########################################
# GLOBAL VARIABLES start with glob_…
##########################################
BEGIN {
FS ="\"" # field separator to quotation mark " (default is " ")
glob_issued="2007/03/05"
glob_modified="2007/09/24"
glob_namespacePrefix="ncd.coll"
glob_namespaceUri="http://rs.tdwg.org/ontology/voc/Collection#"
glob_namespace_isDefinedBy="http://rs.tdwg.org/ontology/voc/Collection"
glob_namespaceUriEncoded="http://rs.tdwg.org/ontology/voc/Collection%23"
}# BEGIN
####### functions start ##################
function ltrim(s) { sub(/^[ \t]+/, "", s); return s }
function rtrim(s) { sub(/[ \t]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
function get_rdfsLabel() {
#<rdfs:label>Collection Identifier</rdfs:label>
return trim(gensub(/.*<(rdfs:label)>(.+)<\/rdfs:label>.*/, "\\2", "g", $0))
}# get_rdfsLabel
function get_attributeValueUrlEncoded() {
# must be FS="\"" !!
#<rdfs:domain rdf:resource="#Collection"/>
firstAttributeValue=$2
if (firstAttributeValue~/^#/) {
firstAttributeValue=gensub(/^#/, glob_namespaceUriEncoded, "g", firstAttributeValue)
} else {
firstAttributeValue=gensub(/#/, "%23", "g", firstAttributeValue)
}
return firstAttributeValue
}# get_attributeValueUrlEncoded
function get_xmlDataElement (xpathQuery) {
# use xml_grep and sed to get trimmed single line values
# "xml_grep xml_grep --text_only --cond \"" xpathQuery "\" " FILENAME " | sed 's@^ *@@;:a;N;$!ba;s/\\n\\t\\+//g;'" | getline output
# has less features, e.g. get only the attribute
"xpath " FILENAME " \"" xpathQuery "\" 2>/dev/null | sed ':a;N;$!ba; s@\\n@@g; s@[ \\t]\\+@ @g;'" | getline output
# 2>/dev/null removes the xpath's script insertions like "-- NODE --"
return output
}
function get_conceptType(typeUrl){
switch (tolower(gensub(/.*#/,"", "g", typeUrl))) {
case "datatypeproperty":
type="data type"
case "class":
type="class"
case "value":
type="value"
default:
type="property"
}
return type
}
function emptyGlobalVariables() {
glob_conceptDefinition = "";
glob_conceptDomain = "";
glob_conceptID = "";
glob_conceptNotes = "";
glob_conceptRange = "";
glob_conceptType = "";
glob_rdfs_isDefinedBy = "";
glob_rdfs_Label = "";
glob_rdfs_subClassOf = "";
glob_rdfs_subPropertyOf = "";
glob_skosCollection = "";
}# emptyGlobalVariables
function create_formLink(conceptID, kindOfConceptComment, startNewOutputSection) {
# use global variables to generate the form link
#### start ####
print ((startNewOutputSection == 0) ? "--> " : "-->\n*" ) \
" {{#formlink: form=Concept\n | link text = " \
glob_namespacePrefix ":" conceptID " [[File:Pencil.png|link=]]\n | target = " glob_namespacePrefix ":" conceptID "\n | query string =<!-- " kindOfConceptComment
if (glob_rdfs_Label) print "-->Concept[label]=" glob_rdfs_Label "<!--"
# append all other fields
if (glob_conceptDefinition) print "-->&Concept[definition]=" trim(glob_conceptDefinition) "<!--"
if (glob_conceptNotes) print "-->&Concept[notes]=" trim(glob_conceptNotes) "<!--"
if (glob_conceptType) print "-->&Concept[concept type]=" trim(glob_conceptType) "<!--"
if (glob_modified) print "-->&Concept[modified]=" gensub("/", "%2F", "g", glob_modified) "<!--"
if (glob_issued) print "-->&Concept[issued]=" gensub("/", "%2F", "g", glob_issued) "<!--"
if (glob_rdfs_isDefinedBy)
print "-->&Concept[is defined by]=<nowiki>" trim(glob_rdfs_isDefinedBy) "</nowiki><!--"
else
print "-->&Concept[is defined by]=<nowiki>" glob_namespace_isDefinedBy "</nowiki><!--"
#if (glob_conceptDomain || glob_conceptRange)
print "-->&Concept scheme relation[1][scheme]=Natural Collections Description<!--"
if (glob_conceptDomain) print "-->&Concept scheme relation[1][property domain]=<nowiki>" trim(glob_conceptDomain) "</nowiki><!--"
if (glob_conceptRange) print "-->&Concept scheme relation[1][property range]=<nowiki>" trim(glob_conceptRange) "</nowiki><!--"
if (glob_rdfs_subPropertyOf) print "-->&Concept relation[1][relation]=rdfs: subproperty of<!--"
if (glob_rdfs_subPropertyOf) print "-->&Concept relation[1][uri]=<nowiki>" trim(glob_rdfs_subPropertyOf) "</nowiki><!--"
if (glob_rdfs_subClassOf) print "-->&Concept relation[1][relation]=rdfs: subclass of<!--"
if (glob_rdfs_subClassOf) print "-->&Concept relation[1][uri]=<nowiki>" trim(glob_rdfs_subClassOf) "</nowiki><!--"
if (glob_skosCollection) print "-->&Concept relation[1][relation]=skos: collection<!--"
if (glob_skosCollection) print "-->&Concept relation[1][internal page]=NCD " trim(glob_skosCollection) "<!--"
#### end ####
print "-->}} │<!--"
emptyGlobalVariables()
}# create_formLink
####### functions end ####################
########## ObjectProperty ################
# in the range of <owl:ObjectProperty … </owl:ObjectProperty> do:
/.*<owl:ObjectProperty/,/.*<\/owl:ObjectProperty>/ {
glob_conceptType = "property"
# <rdfs:comment <rdfs:domain <rdfs:isDefinedBy <rdfs:label <rdfs:range <rdfs:subPropertyOf
# get glob_conceptID in <owl:ObjectProperty rdf:ID="collectionId">
if ($0~/.*<owl:ObjectProperty/) { # print $2 # check data
glob_conceptID=$2
glob_conceptDefinition = get_xmlDataElement("*/owl:ObjectProperty[@rdf:ID='" glob_conceptID "']/rdfs:comment/text()")
}
else {
if ($0~/<rdfs:label/) { glob_rdfs_Label = get_rdfsLabel() }
if ($0~/.*<rdfs:domain/) { glob_conceptDomain = get_attributeValueUrlEncoded() }
# print "domain: " glob_conceptDomain
if ($0~/.*<rdfs:range/) { glob_conceptRange = get_attributeValueUrlEncoded() }
# print "range: " glob_conceptRange
if ($0~/.*<rdfs:isDefinedBy/) { glob_rdfs_isDefinedBy = get_attributeValueUrlEncoded() }
# print "rdfs:isDefinedBy: " glob_rdfs_isDefinedBy
if ($0~/.*<rdfs:subPropertyOf/) { glob_rdfs_subPropertyOf = get_attributeValueUrlEncoded() }
# print "rdfs:subPropertyOf: " glob_rdfs_subPropertyOf
}# definitions within <owl:ObjectProperty>…</owl:ObjectProperty>
if ($0~/.*<\/owl:ObjectProperty>/) {
print create_formLink(glob_conceptID, "ObjectProperty")
}
}# values in ObjectProperty
########## DatatypeProperty ##############
# in the range of <owl:DatatypeProperty … </owl:DatatypeProperty> do:
/<owl:DatatypeProperty/,/<\/owl:DatatypeProperty>/ {
glob_conceptType="data type"
# <rdfs:comment <rdfs:domain <rdfs:isDefinedBy <rdfs:label <rdfs:range <rdfs:subPropertyOf
# get glob_conceptID in <owl:DatatypeProperty rdf:ID="collectionId">
if ($0~/.*<owl:DatatypeProperty/) { # print $2 # check data
glob_conceptID=$2
glob_conceptDefinition = get_xmlDataElement("*/owl:DatatypeProperty[@rdf:ID='" glob_conceptID "']/rdfs:comment/text()")
# print "rdfs:comment (definition): " glob_conceptDefinition
}
else {
if ($0~/.*<rdfs:label/) { glob_rdfs_Label = get_rdfsLabel() }
# print "rdfs:label: " glob_rdfs_Label
if ($0~/.*<rdfs:domain/) { glob_conceptDomain = get_attributeValueUrlEncoded() }
# print "domain: " glob_conceptDomain
if ($0~/.*<rdfs:range/) { glob_conceptRange = get_attributeValueUrlEncoded() }
if ($0~/.*<rdf:type/) { glob_conceptType = get_conceptType(get_attributeValueUrlEncoded()) }
# print "range: " glob_conceptRange
if ($0~/.*<rdfs:isDefinedBy/) { glob_rdfs_isDefinedBy = get_attributeValueUrlEncoded() }
# print "rdfs:isDefinedBy: " glob_rdfs_isDefinedBy
if ($0~/.*<rdfs:subPropertyOf/) { glob_rdfs_subPropertyOf = get_attributeValueUrlEncoded() }
# print "rdfs:subPropertyOf: " glob_rdfs_subPropertyOf
}# definitions within <owl:DatatypeProperty>…</owl:DatatypeProperty>
if ($0~/.*<\/owl:DatatypeProperty>/) {
#### Create the form link ####
print create_formLink(glob_conceptID, "DatatypeProperty")
}
}# values in DatatypeProperty
########## owl:Class and its instances ####
# Classes and instances of a particular class
$0~/<owl:Class/ {# Class definition starts
classNameID=$2
readingOwlClass=classNameID
glob_conceptDefinition = get_xmlDataElement("*/owl:Class[@rdf:ID='" classNameID "']/rdfs:comment/text()")
}# owl:Class
readingOwlClass != "" {
glob_conceptType = "class"
if ($0~/<rdfs:label>/) { glob_rdfs_Label = get_rdfsLabel() }
if ($0~/.*<rdfs:subClassOf/) { glob_rdfs_subClassOf = get_attributeValueUrlEncoded() }
# print "rdfs:subClassOf: " glob_rdfs_subClassOf
if ($0~/.*<rdfs:isDefinedBy/) { glob_rdfs_isDefinedBy = get_attributeValueUrlEncoded() }
# print "rdfs:isDefinedBy: " glob_rdfs_isDefinedBy
if ($0~/.*<rdf:type/) { glob_conceptType = get_conceptType(get_attributeValueUrlEncoded()) }
}
$0~/.*<\/owl:Class>/ {# Class definition closes
readingOwlClass=""
print create_formLink(classNameID, "Class", 1); # separate for output
}
# reading instances of this class
classNameID != "" {
if(index ($0, "<" classNameID ) > 0) {# an instance of the class was found, e.g. <PrimaryGroupingPrincipleTypeTerm …> of <owl:Class rdf:ID="PrimaryGroupingPrincipleTypeTerm">
glob_conceptType="value"
glob_conceptID=$2
readingInstanceOfClass=classNameID
}# a class property found
if(readingInstanceOfClass) {
if ($0~/.*<rdfs:label/) glob_rdfs_Label = get_rdfsLabel() # get_xmlDataElement("*/" classNameID "[@rdf:ID='" glob_conceptID "']/rdfs:label/text()")
if ($0~/.*<rdfs:comment/) glob_conceptNotes = get_xmlDataElement("*/" classNameID "[@rdf:ID='" glob_conceptID "']/rdfs:comment/text()")
if ($0~/.*<dc:title/) { } # don't know yet what to do with it
if ($0~/.*<tbase:definition/) glob_conceptDefinition = get_xmlDataElement("*/" classNameID "[@rdf:ID='" glob_conceptID "']/tbase:definition/text()")
if ($0~/.*<rdfs:subClassOf/) { glob_rdfs_subClassOf = get_attributeValueUrlEncoded() }
if ($0~/.*<rdf:type/) { glob_conceptType = get_conceptType(get_attributeValueUrlEncoded()) }
# no glob_rdfs_subPropertyOf but a glob_skosCollection
glob_skosCollection = classNameID
}
if(index ($0, "</" classNameID ">") > 0) {# the
readingInstanceOfClass=""
print create_formLink(glob_conceptID, "Property in class");
}
}
Collection
- ncd.coll:Collection │
- ncd.coll:DerivedCollection │ ncd.coll:collectionId │ ncd.coll:isPartOfCollection │ ncd.coll:alternativeId │ ncd.coll:descriptionForSpecialists │ ncd.coll:collectionExtent │ ncd.coll:knownToContainTypes │ ncd.coll:primaryGroupingPrinciple │ ncd.coll:primaryPurpose │ ncd.coll:citeAs │ ncd.coll:formationPeriod │ ncd.coll:developmentStatus │ ncd.coll:conservationStatus │ ncd.coll:conservationStatusDate │ ncd.coll:usageRestrictions │ ncd.coll:hasContact │ ncd.coll:hasOwner │ ncd.coll:physicalLocation │ ncd.coll:kingdomCoverage │ ncd.coll:taxonCoverage │ ncd.coll:temporalCoverage │ ncd.coll:taxonCoverageStrength │ ncd.coll:commonNameCoverage │ ncd.coll:commonNameCoverageStrength │ ncd.coll:geospatialCoverage │ ncd.coll:geospatialCoverageStrength │ ncd.coll:geospatialCoordinates │ ncd.coll:livingTimePeriodCoverage │ ncd.coll:livingTimePeriodCoverageStrength │ ncd.coll:collectionType │ ncd.coll:specimenPreservationMethod │ ncd.coll:expeditionNameCoverage │ ncd.coll:collectorNameCoverage │ ncd.coll:relatedCollection │ ncd.coll:itemLevelAccess │
- ncd.coll:DevelopmentStatusTypeTerm │ ncd.coll:activegrowth │ ncd.coll:passivegrowth │ ncd.coll:consumable │ ncd.coll:static │ ncd.coll:decreasing │ ncd.coll:closed │ ncd.coll:lost │ ncd.coll:missing │
- ncd.coll:SpecimenPreservationMethodTypeTerm │ ncd.coll:noTreatment │ ncd.coll:notApplicable │ ncd.coll:fluidPreserved │ ncd.coll:frozen │ ncd.coll:dried │ ncd.coll:driedAndPressed │ ncd.coll:tanned │ ncd.coll:freezeDried │ ncd.coll:glycerin │ ncd.coll:surfaceCoating │ ncd.coll:slideMount │ ncd.coll:embedded │ ncd.coll:pinned │ ncd.coll:controlledAtmosphere │ ncd.coll:cryopreserved │ ncd.coll:recordedAnalog │ ncd.coll:recordedDigital │ ncd.coll:refrigerated │ ncd.coll:semstub │ ncd.coll:skeletonized │ ncd.coll:stasis │
- ncd.coll:PrimaryPurposeTypeTerm │ ncd.coll:research │ ncd.coll:education │ ncd.coll:exhibition │ ncd.coll:ornamental │ ncd.coll:Destructiveanalysis │ ncd.coll:monitoring │ ncd.coll:personal │ ncd.coll:voucher │ ncd.coll:commercial │
- ncd.coll:PrimaryGroupingPrincipleTypeTerm │ ncd.coll:spatial │ ncd.coll:Ecosystems │ ncd.coll:cultural │ ncd.coll:taxonomic │ ncd.coll:relationships │ ncd.coll:expeditions │ ncd.coll:environmental │ ncd.coll:temporal │ ncd.coll:repository │ ncd.coll:national │ ncd.coll:events │ ncd.coll:stage │
- ncd.coll:KingdomTypeTerm │ ncd.coll:Animalia │ ncd.coll:Plantae │ ncd.coll:Fungi │ ncd.coll:Protista │ ncd.coll:Eubacteria │ ncd.coll:Archaebacteria │
- ncd.coll:ConservationStatusTypeTerm │ ncd.coll:McGinley1 │ ncd.coll:McGinley2 │ ncd.coll:McGinley3 │ ncd.coll:McGinley4 │ ncd.coll:McGinley5 │ ncd.coll:McGinley6 │ ncd.coll:McGinley7 │ ncd.coll:McGinley8 │ ncd.coll:McGinley9 │ ncd.coll:McGinley10