From ffde692ee522be0acfab801587617d71573c18c2 Mon Sep 17 00:00:00 2001 From: Alejandro Villar Date: Thu, 3 Oct 2024 12:19:18 +0200 Subject: [PATCH] Add example for new type of transforms --- _sources/feature/geojsonFeature/examples.yaml | 13 +----------- .../geojsonFeature/transforms/sample.shacl | 20 ------------------- .../transforms/transforms-example/bblock.json | 8 ++++++++ .../transforms-example/context.jsonld | 8 ++++++++ .../transforms-example/examples.yaml | 10 ++++++++++ .../transforms/transforms-example/schema.yaml | 8 ++++++++ .../transforms-example/transforms.yaml | 10 ++++++++++ .../transforms/prefix-keys.jq | 1 + .../transforms/prefix-predicates.sparql | 11 ++++++++++ 9 files changed, 57 insertions(+), 32 deletions(-) delete mode 100644 _sources/feature/geojsonFeature/transforms/sample.shacl create mode 100644 _sources/transforms/transforms-example/bblock.json create mode 100644 _sources/transforms/transforms-example/context.jsonld create mode 100644 _sources/transforms/transforms-example/examples.yaml create mode 100644 _sources/transforms/transforms-example/schema.yaml create mode 100644 _sources/transforms/transforms-example/transforms.yaml create mode 100644 _sources/transforms/transforms-example/transforms/prefix-keys.jq create mode 100644 _sources/transforms/transforms-example/transforms/prefix-predicates.sparql diff --git a/_sources/feature/geojsonFeature/examples.yaml b/_sources/feature/geojsonFeature/examples.yaml index d40c837..0a04d63 100644 --- a/_sources/feature/geojsonFeature/examples.yaml +++ b/_sources/feature/geojsonFeature/examples.yaml @@ -5,15 +5,4 @@ base-uri: http://example.com/features/ snippets: - language: json - ref: examples/feature.json - - transforms: - - input-language: application/json - output-language: application/json - type: jq - code: '.properties.myPropUpper = (.properties.myProp | ascii_upcase)' - - - input-language: text/turtle - output-language: text/turtle - type: shacl - ref: transforms/sample.shacl \ No newline at end of file + ref: examples/feature.json \ No newline at end of file diff --git a/_sources/feature/geojsonFeature/transforms/sample.shacl b/_sources/feature/geojsonFeature/transforms/sample.shacl deleted file mode 100644 index fa2a254..0000000 --- a/_sources/feature/geojsonFeature/transforms/sample.shacl +++ /dev/null @@ -1,20 +0,0 @@ -@prefix mymodel: . -@prefix sh: . - - - a sh:NodeShape ; - sh:targetSubjectsOf mymodel:myProp; - sh:rule [ - a sh:SPARQLRule ; - sh:construct """ - prefix dcterms: - prefix mymodel: - CONSTRUCT { - $this dcterms:identifier ?myPropUpper - } WHERE { - $this mymodel:myProp ?myProp - BIND(UCASE(?myProp) as ?myPropUpper) - } - """ - ] ; -. diff --git a/_sources/transforms/transforms-example/bblock.json b/_sources/transforms/transforms-example/bblock.json new file mode 100644 index 0000000..16e871d --- /dev/null +++ b/_sources/transforms/transforms-example/bblock.json @@ -0,0 +1,8 @@ +{ + "name": "Transforms example", + "status": "under-development", + "dateTimeAddition": "2024-10-03T11:31:00+02:00", + "itemClass": "schema", + "version": "0.1", + "dateOfLastChange": "2024-10-03" +} \ No newline at end of file diff --git a/_sources/transforms/transforms-example/context.jsonld b/_sources/transforms/transforms-example/context.jsonld new file mode 100644 index 0000000..1781c7e --- /dev/null +++ b/_sources/transforms/transforms-example/context.jsonld @@ -0,0 +1,8 @@ +{ + "@context": { + "ex": "http://example.com/", + "one": "ex:hasOne", + "two": "ex:hasTwo", + "string": "ex:hasString", + } +} \ No newline at end of file diff --git a/_sources/transforms/transforms-example/examples.yaml b/_sources/transforms/transforms-example/examples.yaml new file mode 100644 index 0000000..af78540 --- /dev/null +++ b/_sources/transforms/transforms-example/examples.yaml @@ -0,0 +1,10 @@ +examples: + - title: Example for transforms + snippets: + - language: json + code: | + { + "one": 1, + "two": 2, + "string": "value" + } \ No newline at end of file diff --git a/_sources/transforms/transforms-example/schema.yaml b/_sources/transforms/transforms-example/schema.yaml new file mode 100644 index 0000000..d49ae86 --- /dev/null +++ b/_sources/transforms/transforms-example/schema.yaml @@ -0,0 +1,8 @@ +type: object +properties: + one: + type: number + two: + type: number + string: + type: string \ No newline at end of file diff --git a/_sources/transforms/transforms-example/transforms.yaml b/_sources/transforms/transforms-example/transforms.yaml new file mode 100644 index 0000000..8b75d9b --- /dev/null +++ b/_sources/transforms/transforms-example/transforms.yaml @@ -0,0 +1,10 @@ +transforms: + - id: prefix-keys + description: Adds a "PREF" prefix to all object keys. + type: jq + ref: transforms/prefix-keys.jq + + - id: prefix-predicates + description: Changes the "http://example.com/" prefix of every predicate to a URN + type: sparql-update + ref: transforms/prefix-predicates.sparql diff --git a/_sources/transforms/transforms-example/transforms/prefix-keys.jq b/_sources/transforms/transforms-example/transforms/prefix-keys.jq new file mode 100644 index 0000000..03692f0 --- /dev/null +++ b/_sources/transforms/transforms-example/transforms/prefix-keys.jq @@ -0,0 +1 @@ +walk(if type == "object" then with_entries( .key |= "PREF\(.)" ) else . end) \ No newline at end of file diff --git a/_sources/transforms/transforms-example/transforms/prefix-predicates.sparql b/_sources/transforms/transforms-example/transforms/prefix-predicates.sparql new file mode 100644 index 0000000..5861f6b --- /dev/null +++ b/_sources/transforms/transforms-example/transforms/prefix-predicates.sparql @@ -0,0 +1,11 @@ +DELETE { + ?s ?p ?o +} +INSERT { + ?s ?p2 ?o +} +WHERE { + ?s ?p ?o + FILTER(STRSTARTS(STR(?p), "http://example.com/")) + BIND(URI(REPLACE(STR(?p), "^http://example.com/", "urn:example:ex#")) as ?p2) +} \ No newline at end of file