Open oschihin opened 2 years ago
For me that looks very related to zazuko/xrm#141. You need it for "constant" and zazuko/xrm#141 in templates. But it's basically the same idea behind it.
@BenjaminHofstetter Yes, it is related, but not the same. I declare URI templates outside the mappings, in a dedicated templates file. But templates ask for a value, typically from a referenced field or column. So I cannot do what I want to do with a template. My property value is a constant URI.
can I use the prefixes defined in vocabularies.xrm?
No, the IRI value of the prefix itself cannot be used as constant.
But with XRM version 1.2.0 comes support for using a class, property or datatype from a vocabulary as a constant value.
Because stabslevels.Fonds
is declared as a class, this should work for the case you described.
properties
...
rico.hasRecordSetType constant stabslevels.Fonds;
XRM version 1.2.0 is not officially released yet, but there is a preview build. I can give you the installation instructions, in case you are interested in using the preview build. What are you using: Eclipse of vscode?
Another workaround is to use a template with fake (unused) parameter and ignore the warnings that are shown:
template const_RecordSetTypes_Fonds "https://ld.staatsarchiv.bs.ch/vocabularies/RecordSetTypes#Fonds"
....
properties
...
rico.hasRecordSetType template const_RecordSetTypes_Fonds with ID_NR; // ID_NR is a fake template parameter
@mchlrch Version 1.2.0 sounds promising. I'd rather do that than ignore the warnings. I am using vscode, so could test the preview (or wait a bit).
@oschihin To install the the preview version of the vscode extension ...
...
button and choose "Install from VSIX…"..vsix
file you downloaded, click Install.Requires Java 11 or newer (JRE or JDK)
@mchlrch Thanks for the extension preview. Will test it, but have only Java 8 at the moment.
@mchlrch a little bit later ... I am on XRM version 1.3, and your example above should work. It doesn't, because using that class declaration does not update declarations in the mapping file:
I do (in mapping.xrm):
map level_archive from stabs_ogd.rr_archive {
subject template rrURI with ID_NR;
types
rico.RecordSet
properties
rico.history from ARCHIVGESCHICHTE with language-tag ger; // @todo: use rico.Event class later
rico.hasRecordSetType constant stabslevels.Archiv;
}
stabslevels.Archiv
is declared as a class in vocabs.xrm
. In the newly generated mapping.carml.ttl
, the prefix stabs-rst
is not declared. Carml throws the error:
error: Undefined prefix "stabs-rst:" on line 131
If I use it in types
, and not as a constant
, the declaration is done.
@mchlrch a little bit later ... I am on XRM version 1.3, and your example above should work. It doesn't, because using that class declaration does not update declarations in the mapping file:
I do (in mapping.xrm):
map level_archive from stabs_ogd.rr_archive { subject template rrURI with ID_NR; types rico.RecordSet properties rico.history from ARCHIVGESCHICHTE with language-tag ger; // @todo: use rico.Event class later rico.hasRecordSetType constant stabslevels.Archiv; }
stabslevels.Archiv
is declared as a class invocabs.xrm
. In the newly generatedmapping.carml.ttl
, the prefixstabs-rst
is not declared. Carml throws the error:error: Undefined prefix "stabs-rst:" on line 131
If I use it in
types
, and not as aconstant
, the declaration is done.
@oschihin That sounds like a bug. Thanks for reporting it
If the property value is a constant, but a URI, not a literal, can I use the prefixes defined in
vocabularies.xrm
?My point illustrated. I have a mapping:
The URI used as constant value is defined like this:
I want to use the prefix. Is there a way or another idea?