zazuko/xrm

URI as a constant value

Opened this issue · 8 comments

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:

map level_fonds from MVK_OGD.VE_FONDS {
	subject template rrURI with ID_NR;

	types
		rico.RecordSet

	properties
		rico.isOrWasIncludedIn template rrURI with PARENT_ID_NR;
		rico.hasRecordSetType constant "https://ld.staatsarchiv.bs.ch/vocabularies/RecordSetTypes#Fonds";
}

The URI used as constant value is defined like this:

prefix "stabs-rst" "https://ld.staatsarchiv.bs.ch/vocabularies/recordSetTypes#"`

I want to use the prefix.
Is there a way or another idea?

For me that looks very related to #141. You need it for "constant" and #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 ...

  1. Download the extension: https://download.zazukoians.org/expressive-rdf-mapper/expressive-rdf-mapper-1.2.0_M2.vsix
  2. Open Visual Studio Code and navigate to the "Extensions" (select View > Extensions from the menu).
  3. Uninstall the currently installed xrm extension
  4. Top-right corner of the "Extensions" pane, use the ... button and choose "Install from VSIX…".
  5. Select the .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-rstis 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 in vocabs.xrm. In the newly generated mapping.carml.ttl, the prefix stabs-rstis 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.

@oschihin That sounds like a bug. Thanks for reporting it