From a225b62eadd7d2f0619eef5c339e83c1a33cd483 Mon Sep 17 00:00:00 2001 From: Michael Rauch Date: Wed, 17 Apr 2024 12:14:31 +0200 Subject: [PATCH] subject from|constant #153 - subject from __ - subject constant __ - graphs from __ --- .../dsl/ide/contentassist/EditorTest.java | 17 +++++++ .../ide/contentassist/EditorTestCsvTest.java | 34 ++++++++++++++ .../contentassist/GraphMapsMappingTest.java | 1 + .../RdfMappingIdeProposalProvider.java | 14 +++--- .../keywordfilter/KeywordFilter.java | 45 ++++++++++--------- .../dsl/tests/ValidationRuleTest.xtend | 38 +++++++++++++++- .../OutputTypeValidationDSLSnippets.xtend | 16 +++++++ .../RdfMappingOutlineTreeProvider.java | 6 +-- .../zazuko/rdfmapping/dsl/RdfMapping.xtext | 19 +++++++- .../formatting2/RealRdfMappingFormatter.xtend | 2 +- .../dsl/generator/common/ModelAccess.xtend | 16 ++++++- .../generator/csvw/CsvwDialectGenerator.xtend | 14 +++--- .../dsl/generator/rml/IRmlDialect.java | 2 +- .../dsl/generator/rml/R2rmlDialect.xtend | 4 +- .../dsl/generator/rml/RmlDialect.xtend | 4 +- .../generator/rml/RmlDialectGenerator.xtend | 36 +++++++-------- .../dsl/validation/RdfMappingValidator.java | 35 ++++++++++++--- .../editor-test/editortest-csv.xrm | 1 + .../editor-test/editortest.xrm | 1 + .../editor-test/foo-mapping-csv.xrm | 2 +- .../editor-test/graphmaps-mapping.xrm | 2 + .../src-gen/graphmaps-mapping.r2rml.ttl | 3 ++ .../legalresource-mapping/.project | 17 +++++++ .../legalresource-mapping.xrm | 11 +++++ .../legalresource-sources.xrm | 14 ++++++ .../src-gen/legalresource-mapping.carml.ttl | 36 +++++++++++++++ .../legalresource-mapping/vocabs.xrm | 18 ++++++++ 27 files changed, 332 insertions(+), 76 deletions(-) create mode 100644 runtime-EclipseXtext/legalresource-mapping/.project create mode 100644 runtime-EclipseXtext/legalresource-mapping/legalresource-mapping.xrm create mode 100644 runtime-EclipseXtext/legalresource-mapping/legalresource-sources.xrm create mode 100644 runtime-EclipseXtext/legalresource-mapping/src-gen/legalresource-mapping.carml.ttl create mode 100644 runtime-EclipseXtext/legalresource-mapping/vocabs.xrm diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTest.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTest.java index 73b62cd1..af13aff7 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTest.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTest.java @@ -15,6 +15,23 @@ public EditorTest() { super("editortest.xrm"); } + @Test + public void keywordsFromConstantTemplateOffered() { + MarkerContext ctx = this.marker("keywordsFromConstantTemplateOffered"); + PositionContext position = ctx.nextLineWithTextAfter("subject"); + + CompletionExpectationBuilder b = new CompletionExpectationBuilder(); + + b.keyword("constant", position); + b.keyword("from", position); + b.keyword("template", position); + + testCompletion((TestCompletionConfiguration it) -> { + position.configure(it); + it.setExpectedCompletionItems(b.toExpectedCompletionItems()); + }); + } + @Test public void getProposalOfTemplatesDefinedInThisFileTest() { MarkerContext ctx = this.marker("getProposalOfTemplatesDefinedInThisFile"); diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTestCsvTest.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTestCsvTest.java index b969293d..8b10bcec 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTestCsvTest.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/EditorTestCsvTest.java @@ -13,6 +13,40 @@ public EditorTestCsvTest() { super("editortest-csv.xrm"); } + @Test + public void noSubjectFromOnCsvTest() { + MarkerContext ctx = this.marker("noSubjectFromOrConstantOnCsv"); + PositionContext position = ctx.nextLineWithTextAfter("subject"); + + CompletionExpectationBuilder b = new CompletionExpectationBuilder(); + + this.assertionMode(AssertEqualsMode.EXPECTED_ABSENT_IN_ACTUAL); + + b.keyword("from", position); + + testCompletion((TestCompletionConfiguration it) -> { + position.configure(it); + it.setExpectedCompletionItems(b.toExpectedCompletionItems()); + }); + } + + @Test + public void noSubjectConstantOnCsvTest() { + MarkerContext ctx = this.marker("noSubjectFromOrConstantOnCsv"); + PositionContext position = ctx.nextLineWithTextAfter("subject"); + + CompletionExpectationBuilder b = new CompletionExpectationBuilder(); + + this.assertionMode(AssertEqualsMode.EXPECTED_ABSENT_IN_ACTUAL); + + b.keyword("constant", position); + + testCompletion((TestCompletionConfiguration it) -> { + position.configure(it); + it.setExpectedCompletionItems(b.toExpectedCompletionItems()); + }); + } + @Test public void noParentTriplesMapOnCsvTest() { MarkerContext ctx = this.marker("noParentTriplesMapOnCsv"); diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/GraphMapsMappingTest.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/GraphMapsMappingTest.java index 9805e87a..f6d238e0 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/GraphMapsMappingTest.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide.tests/src/com/zazuko/rdfmapping/dsl/ide/contentassist/GraphMapsMappingTest.java @@ -21,6 +21,7 @@ public void noAsOnTemplateValueInGraphMappingsTest() { CompletionExpectationBuilder b = new CompletionExpectationBuilder(); b.ref("id", Referenceable.class, position); + b.ref("someIri", Referenceable.class, position); b.keyword(";", position); // NOT b.keyword("as", position); diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/RdfMappingIdeProposalProvider.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/RdfMappingIdeProposalProvider.java index cf01d4d8..fb38949a 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/RdfMappingIdeProposalProvider.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/RdfMappingIdeProposalProvider.java @@ -3,8 +3,6 @@ import java.util.Collection; import java.util.Set; -import jakarta.inject.Inject; - import org.eclipse.xtext.Assignment; import org.eclipse.xtext.Keyword; import org.eclipse.xtext.RuleCall; @@ -22,11 +20,12 @@ import com.zazuko.rdfmapping.dsl.rdfMapping.Mapping; import com.zazuko.rdfmapping.dsl.rdfMapping.OmniMap; import com.zazuko.rdfmapping.dsl.rdfMapping.PredicateObjectMapping; -import com.zazuko.rdfmapping.dsl.rdfMapping.ReferenceValuedTerm; import com.zazuko.rdfmapping.dsl.rdfMapping.SourceGroup; -import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValuedTerm; +import com.zazuko.rdfmapping.dsl.rdfMapping.ValuedTerm; import com.zazuko.rdfmapping.dsl.services.RdfMappingGrammarAccess; +import jakarta.inject.Inject; + public class RdfMappingIdeProposalProvider extends IdeContentProposalProvider { @Inject @@ -74,11 +73,8 @@ protected boolean filterKeyword(Keyword keyword, ContentAssistContext context) { if (context.getCurrentModel() instanceof PredicateObjectMapping) { return this.keywordFilter.filter((PredicateObjectMapping) context.getCurrentModel(), keyword, context); - } else if (context.getCurrentModel() instanceof ReferenceValuedTerm) { - return this.keywordFilter.filter((ReferenceValuedTerm) context.getCurrentModel(), keyword, context); - - } else if (context.getCurrentModel() instanceof TemplateValuedTerm) { - return this.keywordFilter.filter((TemplateValuedTerm) context.getCurrentModel(), keyword, context); + } else if (context.getCurrentModel() instanceof ValuedTerm) { + return this.keywordFilter.filter((ValuedTerm) context.getCurrentModel(), keyword, context); } else if (context.getCurrentModel() instanceof SourceGroup) { return this.keywordFilter.filter((SourceGroup) context.getCurrentModel(), keyword, context); diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/keywordfilter/KeywordFilter.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/keywordfilter/KeywordFilter.java index e33195a7..03d77a5f 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/keywordfilter/KeywordFilter.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ide/src/com/zazuko/rdfmapping/dsl/ide/contentassist/keywordfilter/KeywordFilter.java @@ -3,8 +3,6 @@ import java.util.Collections; import java.util.function.Predicate; -import jakarta.inject.Inject; - import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.Keyword; import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext; @@ -15,10 +13,11 @@ import com.zazuko.rdfmapping.dsl.rdfMapping.Mapping; import com.zazuko.rdfmapping.dsl.rdfMapping.OutputType; import com.zazuko.rdfmapping.dsl.rdfMapping.PredicateObjectMapping; -import com.zazuko.rdfmapping.dsl.rdfMapping.ReferenceValuedTerm; import com.zazuko.rdfmapping.dsl.rdfMapping.SourceGroup; import com.zazuko.rdfmapping.dsl.rdfMapping.SourceType; -import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValuedTerm; +import com.zazuko.rdfmapping.dsl.rdfMapping.ValuedTerm; + +import jakarta.inject.Inject; public class KeywordFilter { @@ -33,37 +32,34 @@ public boolean filter(PredicateObjectMapping in, Keyword keyword, ContentAssistC return filter.test(keyword); } - public boolean filter(ReferenceValuedTerm in, Keyword keyword, ContentAssistContext context) { - Predicate filter = this.referencedValueTermFilter(in); - return filter.test(keyword); - } - - private Predicate referencedValueTermFilter(EObject in) { - OutputType type = modelAccess.outputType(in); - return new RmlishOutputTypeCompletionProposalPredicate("as", type); - } - - public boolean filter(TemplateValuedTerm in, Keyword keyword, ContentAssistContext context) { - Predicate filter = this.referencedValueTermFilter(in); + public boolean filter(ValuedTerm in, Keyword keyword, ContentAssistContext context) { + Predicate filter = this.valuedTermFilter(in); EObject container = in.eContainer(); - // #30 for a subjectIriMapping, don't offer 'Literal' if (container instanceof Mapping) { Mapping mapping = (Mapping) container; - // make sure we really have subjetIriMapping in our hands - if (mapping.getSubjectIriMapping() == in) { + + // make sure we really have subjetMapping in our hands + if (mapping.getSubjectMapping() == in) { + + // #30 for a subjectMapping, don't offer 'Literal' filter = filter.and(new BlacklistedCompletionProposalPredicate("Literal")); } } if (container instanceof GraphMapping) { - // within a graphMapping, 'as' is not a viable option for a TemplateValuedTerm + // within a graphMapping, 'as' is not a viable option for a ValuedTerm filter = filter.and(new BlacklistedCompletionProposalPredicate("as")); } return filter.test(keyword); } + + private Predicate valuedTermFilter(EObject in) { + OutputType type = modelAccess.outputType(in); + return new RmlishOutputTypeCompletionProposalPredicate("as", type); + } public boolean filter(SourceGroup in, Keyword keyword, ContentAssistContext context) { return this.completeKeywordForSourceDefinition(keyword, @@ -76,8 +72,13 @@ public boolean filter(LogicalSource in, Keyword keyword, ContentAssistContext co } public boolean filter(Mapping in, Keyword keyword, ContentAssistContext context) { - OutputType type = this.modelAccess.outputType(in); - return new RmlishOutputTypeCompletionProposalPredicate("graphs", type).test(keyword); + OutputType outputType = this.modelAccess.outputType(in); + + Predicate filter = new RmlishOutputTypeCompletionProposalPredicate("graphs", outputType); + filter = filter.and(new RmlishOutputTypeCompletionProposalPredicate("from", outputType)); + filter = filter.and(new RmlishOutputTypeCompletionProposalPredicate("constant", outputType)); + + return filter.test(keyword); } private boolean completeKeywordForSourceDefinition(Keyword keyword, SourceType type) { diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/ValidationRuleTest.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/ValidationRuleTest.xtend index 5e67f75c..d0c3f5dd 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/ValidationRuleTest.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/ValidationRuleTest.xtend @@ -267,7 +267,7 @@ class ValidationRuleTest { } @Test - def void rmp_parentMap_ok() { + def void rml_parentMap_ok() { val result = parseHelper.parse(outputTypeSnippets.outputType_propertiesmapping("rml", '''employee.one parent-map EmployeeMapping2;''')); validationTester.assertNoErrors(result); @@ -339,6 +339,42 @@ class ValidationRuleTest { ); } + @Test + def void rml_subjectFrom_ok() { + val result = parseHelper.parse(outputTypeSnippets.outputType_subjectMapping("rml", '''from id''')); + + validationTester.assertNoErrors(result); + } + + @Test + def void csv_subjectFrom_onRmlishOnly() { + val result = parseHelper.parse(outputTypeSnippets.outputType_subjectMapping("csvw", '''from id''')); + + validationTester.assertWarning(result, + RdfMappingPackage.eINSTANCE.referenceValuedTerm, + RdfMappingValidationCodes.EOBJECT_SUPERFLUOUS, + "Not on output of type 'csvw' - only valid on [rml, r2rml, carml]" + ); + } + + @Test + def void rml_subjectConstant_ok() { + val result = parseHelper.parse(outputTypeSnippets.outputType_subjectMapping("rml", '''constant "http://airport.example.org/BIU"''')); + + validationTester.assertNoErrors(result); + } + + @Test + def void csv_subjectConstant_onRmlishOnly() { + val result = parseHelper.parse(outputTypeSnippets.outputType_subjectMapping("csvw", '''constant "http://airport.example.org/BIU"''')); + + validationTester.assertWarning(result, + RdfMappingPackage.eINSTANCE.constantValuedTerm, + RdfMappingValidationCodes.EOBJECT_SUPERFLUOUS, + "Not on output of type 'csvw' - only valid on [rml, r2rml, carml]" + ); + } + @Test def void mapping_graphMap_templateWithTermType() { val result = parseHelper.parse(mappingSnippets.graphMap_templateWithTermType()); diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/snippets/OutputTypeValidationDSLSnippets.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/snippets/OutputTypeValidationDSLSnippets.xtend index 57b67c8d..1191301f 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/snippets/OutputTypeValidationDSLSnippets.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.tests/src/com/zazuko/rdfmapping/dsl/tests/snippets/OutputTypeValidationDSLSnippets.xtend @@ -46,6 +46,22 @@ class OutputTypeValidationDSLSnippets { } ''' + def outputType_subjectMapping(String outputType, String subjectMapping) ''' + output «outputType» + + map EmployeeMapping1 from EMPLOYEE1 { + subject «subjectMapping»; + } + + logical-source EMPLOYEE1 { + type csv + source "EMP" + + referenceables + id + } + ''' + def outputTypeWithoutMapping() ''' output csvw diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ui/src/com/zazuko/rdfmapping/dsl/ui/outline/RdfMappingOutlineTreeProvider.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ui/src/com/zazuko/rdfmapping/dsl/ui/outline/RdfMappingOutlineTreeProvider.java index b9b8ba8b..114bf082 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ui/src/com/zazuko/rdfmapping/dsl/ui/outline/RdfMappingOutlineTreeProvider.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl.ui/src/com/zazuko/rdfmapping/dsl/ui/outline/RdfMappingOutlineTreeProvider.java @@ -12,7 +12,7 @@ import com.zazuko.rdfmapping.dsl.rdfMapping.Prefix; import com.zazuko.rdfmapping.dsl.rdfMapping.Referenceable; import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateDeclaration; -import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValuedTerm; +import com.zazuko.rdfmapping.dsl.rdfMapping.ValuedTerm; import com.zazuko.rdfmapping.dsl.rdfMapping.Vocabulary; /** @@ -24,7 +24,7 @@ public class RdfMappingOutlineTreeProvider extends DefaultOutlineTreeProvider { protected void _createChildren(DocumentRootNode parentNode, Mapping mapping) { - createNode(parentNode, mapping.getSubjectIriMapping()); + createNode(parentNode, mapping.getSubjectMapping()); } protected void _createChildren(DocumentRootNode parentNode, Vocabulary v) { @@ -35,7 +35,7 @@ protected void _createNode(IOutlineNode parentNode, Prefix modelElement) { } - protected void _createNode(IOutlineNode parentNode, TemplateValuedTerm modelElement) { + protected void _createNode(IOutlineNode parentNode, ValuedTerm modelElement) { } diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/RdfMapping.xtext b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/RdfMapping.xtext index 6f4c0f88..c1b69e03 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/RdfMapping.xtext +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/RdfMapping.xtext @@ -148,7 +148,7 @@ TemplateValueRef: Mapping: 'map' name=ID 'from' source=[LogicalSource|QualifiedName] BLOCK_BEGIN - 'subject' subjectIriMapping=TemplateValuedTerm LINE_END + 'subject' subjectMapping=SubjectMapping LINE_END ('graphs' (graphMappings+=GraphMapping)+)? ('types' (subjectTypeMappings+=SubjectTypeMapping)+)? ('properties' (poMappings+=PredicateObjectMapping)+)? @@ -158,8 +158,14 @@ SubjectTypeMapping: type=[RdfClass|RdfPrefixedName] ; +SubjectMapping returns ValuedTerm: + TemplateValuedTerm + | ConstantValuedTerm + | SubjectReferenceValuedTerm +; + GraphMapping: - (template=TemplateValuedTerm | constant=ConstantValuedTerm) LINE_END + (template=TemplateValuedTerm | constant=ConstantValuedTerm | reference=GraphMappingReferenceValuedTerm) LINE_END ; PredicateObjectMapping: @@ -183,6 +189,15 @@ ReferenceValuedTerm: ('as' termTypeRef=TermTypeRef)? ; +SubjectReferenceValuedTerm returns ReferenceValuedTerm: + 'from' reference=[Referenceable] + ('as' termTypeRef=TermTypeRef)? +; + +GraphMappingReferenceValuedTerm returns ReferenceValuedTerm: + 'from' reference=[Referenceable] +; + MultiReferenceValuedTerm: 'multi-reference' 'from' reference=[Referenceable] ('with' 'datatype' datatype=[Datatype|RdfPrefixedName] | 'with' 'language-tag' languageTag=[LanguageTag])? diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/formatting2/RealRdfMappingFormatter.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/formatting2/RealRdfMappingFormatter.xtend index c05b7b9b..fd7b4999 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/formatting2/RealRdfMappingFormatter.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/formatting2/RealRdfMappingFormatter.xtend @@ -251,7 +251,7 @@ class RealRdfMappingFormatter extends AbstractFormatter2 { regionFor.ruleCall(ga.mappingAccess.BLOCK_BEGINTerminalRuleCall_4).append[setNewLines(1)]; regionFor.keyword(ga.mappingAccess.subjectKeyword_5).append[oneSpace]; - subjectIriMapping?.format; + subjectMapping?.format; regionFor.ruleCall(ga.mappingAccess.LINE_ENDTerminalRuleCall_7).prepend[noSpace]; // 'graphs' diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/common/ModelAccess.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/common/ModelAccess.xtend index ec893679..bd5b9bb8 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/common/ModelAccess.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/common/ModelAccess.xtend @@ -5,12 +5,14 @@ import com.zazuko.rdfmapping.dsl.generator.common.extractors.DialectGroupExtract import com.zazuko.rdfmapping.dsl.generator.common.extractors.IsQueryResolvedExtractor import com.zazuko.rdfmapping.dsl.generator.common.extractors.SourceExtractor import com.zazuko.rdfmapping.dsl.generator.common.extractors.XmlNamespaceExtensionExtractor +import com.zazuko.rdfmapping.dsl.rdfMapping.ConstantValuedTerm import com.zazuko.rdfmapping.dsl.rdfMapping.Datatype import com.zazuko.rdfmapping.dsl.rdfMapping.DialectGroup import com.zazuko.rdfmapping.dsl.rdfMapping.Domainmodel import com.zazuko.rdfmapping.dsl.rdfMapping.Element import com.zazuko.rdfmapping.dsl.rdfMapping.LogicalSource import com.zazuko.rdfmapping.dsl.rdfMapping.Mapping +import com.zazuko.rdfmapping.dsl.rdfMapping.MultiReferenceValuedTerm import com.zazuko.rdfmapping.dsl.rdfMapping.NullValueDeclaration import com.zazuko.rdfmapping.dsl.rdfMapping.OutputType import com.zazuko.rdfmapping.dsl.rdfMapping.PredicateObjectMapping @@ -22,17 +24,18 @@ import com.zazuko.rdfmapping.dsl.rdfMapping.SourceType import com.zazuko.rdfmapping.dsl.rdfMapping.SourceTypeRef import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValueDeclaration import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValueRef +import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValuedTerm +import com.zazuko.rdfmapping.dsl.rdfMapping.TermTypeRef import com.zazuko.rdfmapping.dsl.rdfMapping.ValuedTerm import com.zazuko.rdfmapping.dsl.rdfMapping.Vocabulary import com.zazuko.rdfmapping.dsl.rdfMapping.VocabularyElement import com.zazuko.rdfmapping.dsl.rdfMapping.XmlNamespaceExtension +import jakarta.inject.Inject import java.net.URL import java.util.LinkedHashSet import java.util.List import java.util.Set -import jakarta.inject.Inject import org.eclipse.emf.ecore.EObject -import com.zazuko.rdfmapping.dsl.rdfMapping.ConstantValuedTerm class ModelAccess { @@ -207,5 +210,14 @@ class ModelAccess { def String csvNullValue(LogicalSource it) { return csvNullValueExtractor.extractC(it); } + + def TermTypeRef termTypeRef0(ValuedTerm it) { + switch it { + ReferenceValuedTerm : termTypeRef + MultiReferenceValuedTerm : termTypeRef + TemplateValuedTerm : termTypeRef + default : null + } + } } diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/csvw/CsvwDialectGenerator.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/csvw/CsvwDialectGenerator.xtend index ed9d6982..950a3df8 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/csvw/CsvwDialectGenerator.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/csvw/CsvwDialectGenerator.xtend @@ -16,6 +16,7 @@ import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValuedTerm import java.text.MessageFormat import java.util.List import jakarta.inject.Inject +import com.zazuko.rdfmapping.dsl.rdfMapping.ValuedTerm class CsvwDialectGenerator { @@ -128,8 +129,15 @@ class CsvwDialectGenerator { }«jc.acquireMarker» «ENDFOR» ''' + + def subjectMap(Mapping it) '''"aboutUrl": "«subjectMapping.aboutUrl»"''' + + def dispatch aboutUrl(TemplateValuedTerm it) { + return toTemplateString; + } - def subjectMap(Mapping it) '''"aboutUrl": "«subjectIri»"''' + def dispatch aboutUrl(ValuedTerm it) ''' + «class.name» not supported''' def columns(Mapping it, IJoinContext jc) ''' «FOR pom : poMappings» @@ -174,10 +182,6 @@ class CsvwDialectGenerator { «ENDIF» ''' - def subjectIri(Mapping it) { - subjectIriMapping.toTemplateString - } - def toTemplateString(TemplateValuedTerm it) { template.apply(references); } diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/IRmlDialect.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/IRmlDialect.java index 9b179a4f..5f9be2d7 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/IRmlDialect.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/IRmlDialect.java @@ -7,6 +7,6 @@ public interface IRmlDialect { CharSequence staticPrefixes(); CharSequence logicalSource(Mapping m, IJoinContext jc); - CharSequence objectMapReferencePredicate(); + CharSequence termMapReferencePredicate(); CharSequence objectMapMultiReferencePredicate(); } diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/R2rmlDialect.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/R2rmlDialect.xtend index cc0d6348..6bd7b52a 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/R2rmlDialect.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/R2rmlDialect.xtend @@ -20,10 +20,10 @@ class R2rmlDialect implements IRmlDialect { def sourceStatement( LogicalSource it) '''«IF sourceIsQueryResolved»rr:sqlQuery """«sourceResolved»"""«ELSE»rr:tableName "«sourceResolved»"«ENDIF»''' - override objectMapReferencePredicate() '''rr:column''' + override termMapReferencePredicate() '''rr:column''' // R2ML does no support multiReference override objectMapMultiReferencePredicate() { - return objectMapReferencePredicate() + return termMapReferencePredicate() } } diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialect.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialect.xtend index cf304985..a7eded2a 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialect.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialect.xtend @@ -32,11 +32,11 @@ class RmlDialect implements IRmlDialect { «ENDIF» ''' - override objectMapReferencePredicate() '''rml:reference''' + override termMapReferencePredicate() '''rml:reference''' // Plain RML does no support multiReference. CarmlDialect overrides this with 'carml:multiReference' override objectMapMultiReferencePredicate() { - return objectMapReferencePredicate() + return termMapReferencePredicate() } } diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialectGenerator.xtend b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialectGenerator.xtend index c527cd57..a16f6353 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialectGenerator.xtend +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/generator/rml/RmlDialectGenerator.xtend @@ -17,9 +17,9 @@ import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValue import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValuedTerm import com.zazuko.rdfmapping.dsl.rdfMapping.TermTypeRef import com.zazuko.rdfmapping.dsl.rdfMapping.ValuedTerm +import jakarta.inject.Inject import java.text.MessageFormat import java.util.List -import jakarta.inject.Inject class RmlDialectGenerator { @@ -77,13 +77,10 @@ class RmlDialectGenerator { def subjectMap(Mapping it, IJoinContext jc) ''' rr:subjectMap [ - rr:template "«subjectIri»"«jc.acquireMarker» + «subjectMapping.termMap(jc)» «FOR stm : subjectTypeMappings» rr:class «stm.type.vocabulary.prefix.label»:«stm.type.valueResolved»«jc.acquireMarker» «ENDFOR» - «IF subjectIriMapping.termTypeRef?.type !== null» - rr:termType rr:«subjectIriMapping.termTypeRef.type»«jc.acquireMarker» - «ENDIF» «FOR graphMapping : graphMappings» «graphMap(graphMapping, jc.newContext)»«jc.acquireMarker» «ENDFOR» @@ -94,6 +91,8 @@ class RmlDialectGenerator { return graphMap(template, jc); } else if (constant !== null) { return graphMap(constant, jc); + } else if (reference !== null) { + return graphMap(reference, jc); } return ""; } @@ -107,31 +106,36 @@ class RmlDialectGenerator { def graphMap(ConstantValuedTerm it, IJoinContext jc) ''' rr:graphMap [ rr:constant «toConstantValue»«jc.acquireMarker» - ]''' + ]''' + + def graphMap(ReferenceValuedTerm it, IJoinContext jc) ''' + rr:graphMap [ + «termMapReferencePredicate» "«reference.valueResolved»"«jc.acquireMarker» + ]''' def predicateObjectMap(PredicateObjectMapping it, IJoinContext jc) ''' rr:predicateObjectMap [ rr:predicate «property.vocabulary.prefix.label»:«property.valueResolved»«jc.acquireMarker» rr:objectMap [ - «term.objectTermMap(jc.newContext)» + «term.termMap(jc.newContext)» ]«jc.acquireMarker» ]''' - def dispatch objectTermMap(ValuedTerm it, IJoinContext jc) ''' + def dispatch termMap(ValuedTerm it, IJoinContext jc) ''' # TODO: implementation missing for «class.name» ''' - def dispatch objectTermMap(ReferenceValuedTerm it, IJoinContext jc) ''' - «objectMapReferencePredicate» "«reference.valueResolved»"«jc.acquireMarker» + def dispatch termMap(ReferenceValuedTerm it, IJoinContext jc) ''' + «termMapReferencePredicate» "«reference.valueResolved»"«jc.acquireMarker» «termMapAnnex(jc)» ''' - def dispatch objectTermMap(MultiReferenceValuedTerm it, IJoinContext jc) ''' + def dispatch termMap(MultiReferenceValuedTerm it, IJoinContext jc) ''' «objectMapMultiReferencePredicate» "«reference.valueResolved»"«jc.acquireMarker» «termMapAnnex(jc)» ''' - def dispatch objectTermMap(ConstantValuedTerm it, IJoinContext jc) ''' + def dispatch termMap(ConstantValuedTerm it, IJoinContext jc) ''' rr:constant «toConstantValue»«jc.acquireMarker» ''' @@ -147,14 +151,14 @@ class RmlDialectGenerator { } } - def dispatch objectTermMap(TemplateValuedTerm it, IJoinContext jc) ''' + def dispatch termMap(TemplateValuedTerm it, IJoinContext jc) ''' rr:template "«toTemplateString»"«jc.acquireMarker» «IF termTypeRef?.type !== null» rr:termType rr:«termTypeRef.type»«jc.acquireMarker» «ENDIF» ''' - def dispatch objectTermMap(ParentTriplesMapTerm it, IJoinContext jc) ''' + def dispatch termMap(ParentTriplesMapTerm it, IJoinContext jc) ''' rr:parentTriplesMap <«mapping.localId»>«jc.acquireMarker» «FOR join : joinConditions» rr:joinCondition [ @@ -185,10 +189,6 @@ class RmlDialectGenerator { def private localId(Mapping it) '''#«name»''' - def subjectIri(Mapping it) { - subjectIriMapping.toTemplateString - } - def toTemplateString(TemplateValuedTerm it) { template.apply(references); } diff --git a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/validation/RdfMappingValidator.java b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/validation/RdfMappingValidator.java index c50b8d16..369fbe1d 100644 --- a/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/validation/RdfMappingValidator.java +++ b/com.zazuko.rdfmapping.dsl.parent/com.zazuko.rdfmapping.dsl/src/com/zazuko/rdfmapping/dsl/validation/RdfMappingValidator.java @@ -7,8 +7,6 @@ import java.util.TreeMap; import java.util.stream.Collectors; -import jakarta.inject.Inject; - import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.xtext.validation.Check; @@ -17,6 +15,7 @@ import com.zazuko.rdfmapping.dsl.common.RdfMappingConstants; import com.zazuko.rdfmapping.dsl.common.RdfMappingValidationCodes; import com.zazuko.rdfmapping.dsl.generator.common.ModelAccess; +import com.zazuko.rdfmapping.dsl.rdfMapping.ConstantValuedTerm; import com.zazuko.rdfmapping.dsl.rdfMapping.Datatype; import com.zazuko.rdfmapping.dsl.rdfMapping.DialectGroup; import com.zazuko.rdfmapping.dsl.rdfMapping.Domainmodel; @@ -36,6 +35,7 @@ import com.zazuko.rdfmapping.dsl.rdfMapping.RdfClass; import com.zazuko.rdfmapping.dsl.rdfMapping.RdfMappingPackage; import com.zazuko.rdfmapping.dsl.rdfMapping.RdfProperty; +import com.zazuko.rdfmapping.dsl.rdfMapping.ReferenceValuedTerm; import com.zazuko.rdfmapping.dsl.rdfMapping.Referenceable; import com.zazuko.rdfmapping.dsl.rdfMapping.SourceGroup; import com.zazuko.rdfmapping.dsl.rdfMapping.SourceType; @@ -51,6 +51,8 @@ import com.zazuko.rdfmapping.dsl.util.LazyMap; import com.zazuko.rdfmapping.dsl.validation.TemplateFormatAnalyzer.TemplateFormatAnalyzerException; +import jakarta.inject.Inject; + /** * This class contains custom validation rules. * @@ -316,14 +318,33 @@ public void check(Mapping it) { } } - // no literal on subjectIriMapping - if (it.getSubjectIriMapping() != null && it.getSubjectIriMapping().getTermTypeRef() != null - && TermType.LITERAL.equals(it.getSubjectIriMapping().getTermTypeRef().getType())) { - error("Literal is invalid on the subject", it.getSubjectIriMapping().getTermTypeRef(), - RdfMappingPackage.Literals.TERM_TYPE_REF__TYPE); + } + + @Check + public void checkSubjectMapping(ValuedTerm it) { + if (!(it.eContainer() instanceof Mapping)) { + return; + } + Mapping mapping = (Mapping) it.eContainer(); + + // make sure we are looking at the subjectMapping + if (it.equals(mapping.getSubjectMapping())) { + + // no TermType literal on subjectMapping + if (this.modelAccess.termTypeRef0(it) != null + && TermType.LITERAL.equals(this.modelAccess.termTypeRef0(it).getType())) { + error("TermType Literal is invalid on the subject", this.modelAccess.termTypeRef0(it), + RdfMappingPackage.Literals.TERM_TYPE_REF__TYPE); + } } + if (it instanceof ReferenceValuedTerm) { + onlyOnRmlishType(this.modelAccess.outputType(it), null); + } + if (it instanceof ConstantValuedTerm) { + onlyOnRmlishType(this.modelAccess.outputType(it), null); + } } @Check diff --git a/runtime-EclipseXtext/editor-test/editortest-csv.xrm b/runtime-EclipseXtext/editor-test/editortest-csv.xrm index 601ce10e..a7510f72 100644 --- a/runtime-EclipseXtext/editor-test/editortest-csv.xrm +++ b/runtime-EclipseXtext/editor-test/editortest-csv.xrm @@ -4,6 +4,7 @@ output csvw template anyTemplate "foo2" map EmployeeMappingCsv from EMPLOYEEeditorTest { + // AUTOTEST noSubjectFromOrConstantOnCsv subject template "http://airport.example.com/{0}" with id; types diff --git a/runtime-EclipseXtext/editor-test/editortest.xrm b/runtime-EclipseXtext/editor-test/editortest.xrm index 74ded6f1..4c15df18 100644 --- a/runtime-EclipseXtext/editor-test/editortest.xrm +++ b/runtime-EclipseXtext/editor-test/editortest.xrm @@ -42,6 +42,7 @@ map EmployeeMapping from EMPLOYEE { } map EmployeeMapping2 from EMPLOYEE { + // AUTOTEST keywordsFromConstantTemplateOffered subject template "http://airport.example.com/{0}" with id; types diff --git a/runtime-EclipseXtext/editor-test/foo-mapping-csv.xrm b/runtime-EclipseXtext/editor-test/foo-mapping-csv.xrm index 350b1048..37df5fe9 100644 --- a/runtime-EclipseXtext/editor-test/foo-mapping-csv.xrm +++ b/runtime-EclipseXtext/editor-test/foo-mapping-csv.xrm @@ -7,7 +7,7 @@ map TestImpactMappingCsv from SomeSourceGroup.fooCsv { // TODO uncomment next two lines --> warning (no graphs on CSVW) // graphs -// constant "blubb" +// constant "blubb"; types employee.Employee diff --git a/runtime-EclipseXtext/editor-test/graphmaps-mapping.xrm b/runtime-EclipseXtext/editor-test/graphmaps-mapping.xrm index 201047cd..dc65bdac 100644 --- a/runtime-EclipseXtext/editor-test/graphmaps-mapping.xrm +++ b/runtime-EclipseXtext/editor-test/graphmaps-mapping.xrm @@ -16,6 +16,7 @@ map ThingIntoGraphmapsMapping from ThingIntoGraphmapsSource { constant thing.Thing; constant thing.color; constant employee.myDatatype; + from someIri; types thing.Thing @@ -31,4 +32,5 @@ logical-source ThingIntoGraphmapsSource { referenceables id + someIri } \ No newline at end of file diff --git a/runtime-EclipseXtext/editor-test/src-gen/graphmaps-mapping.r2rml.ttl b/runtime-EclipseXtext/editor-test/src-gen/graphmaps-mapping.r2rml.ttl index 0522fbae..6f1a11f5 100644 --- a/runtime-EclipseXtext/editor-test/src-gen/graphmaps-mapping.r2rml.ttl +++ b/runtime-EclipseXtext/editor-test/src-gen/graphmaps-mapping.r2rml.ttl @@ -27,6 +27,9 @@ PREFIX thing: ]; rr:graphMap [ rr:constant employee:myDatatype + ]; + rr:graphMap [ + rr:column "someIri" ] ]; diff --git a/runtime-EclipseXtext/legalresource-mapping/.project b/runtime-EclipseXtext/legalresource-mapping/.project new file mode 100644 index 00000000..1fe7f61b --- /dev/null +++ b/runtime-EclipseXtext/legalresource-mapping/.project @@ -0,0 +1,17 @@ + + + legalresource-mapping + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/runtime-EclipseXtext/legalresource-mapping/legalresource-mapping.xrm b/runtime-EclipseXtext/legalresource-mapping/legalresource-mapping.xrm new file mode 100644 index 00000000..fd7795cc --- /dev/null +++ b/runtime-EclipseXtext/legalresource-mapping/legalresource-mapping.xrm @@ -0,0 +1,11 @@ +output carml + +map LegalResource from Work { + subject from legalResourceIri; + + types + eli.LegalResource + + properties + eli.date_document from docdate with datatype xsd.date; +} \ No newline at end of file diff --git a/runtime-EclipseXtext/legalresource-mapping/legalresource-sources.xrm b/runtime-EclipseXtext/legalresource-mapping/legalresource-sources.xrm new file mode 100644 index 00000000..67e8e14b --- /dev/null +++ b/runtime-EclipseXtext/legalresource-mapping/legalresource-sources.xrm @@ -0,0 +1,14 @@ +logical-source Work { + type xml + source "stdin" + xml-namespace-extension akomaNtoso + iterator "/akn:akomaNtoso/akn:act/akn:meta/akn:identification/akn:FRBRWork" + + referenceables + legalResourceIri "concat('http://zrh.ch', akn:FRBRuri/@value)" + docdate "tokenize(akn:FRBRuri/@value, '/')[5]" +} + +xml-namespace-extension akomaNtoso { + prefix "akn" "http://docs.oasis-open.org/legaldocml/ns/akn/3.0" +} \ No newline at end of file diff --git a/runtime-EclipseXtext/legalresource-mapping/src-gen/legalresource-mapping.carml.ttl b/runtime-EclipseXtext/legalresource-mapping/src-gen/legalresource-mapping.carml.ttl new file mode 100644 index 00000000..5e720385 --- /dev/null +++ b/runtime-EclipseXtext/legalresource-mapping/src-gen/legalresource-mapping.carml.ttl @@ -0,0 +1,36 @@ +PREFIX rr: +PREFIX rml: +PREFIX ql: +PREFIX carml: +PREFIX eli: +PREFIX xsd: + +<#LegalResource> + a rr:TriplesMap; + + rml:logicalSource [ + rml:source [ + a carml:Stream; + carml:streamName "stdin"; + carml:declaresNamespace [ + carml:namespacePrefix "akn"; + carml:namespaceName "http://docs.oasis-open.org/legaldocml/ns/akn/3.0" + ] + ]; + rml:referenceFormulation ql:XPath; + rml:iterator "/akn:akomaNtoso/akn:act/akn:meta/akn:identification/akn:FRBRWork" + ]; + + rr:subjectMap [ + rml:reference "concat('http://zrh.ch', akn:FRBRuri/@value)"; + rr:class eli:LegalResource + ]; + + rr:predicateObjectMap [ + rr:predicate eli:date_document; + rr:objectMap [ + rml:reference "tokenize(akn:FRBRuri/@value, '/')[5]"; + rr:datatype xsd:date + ] + ]. + diff --git a/runtime-EclipseXtext/legalresource-mapping/vocabs.xrm b/runtime-EclipseXtext/legalresource-mapping/vocabs.xrm new file mode 100644 index 00000000..038b1f93 --- /dev/null +++ b/runtime-EclipseXtext/legalresource-mapping/vocabs.xrm @@ -0,0 +1,18 @@ +vocabulary xsd { + prefix "xsd" "http://www.w3.org/2001/XMLSchema#" + + datatypes + anyURI + date +} + +vocabulary eli { + prefix "eli" "http://data.europa.eu/eli/ontology#" + + classes + LegalResource + + properties + date_document +} +