herminiogg / ShExML

A heterogeneous data mapping language based on Shape Expressions
http://shexml.herminiogarcia.com
MIT License
15 stars 2 forks source link

Using value sets in ShExML #142

Closed andrawaag closed 1 year ago

andrawaag commented 1 year ago

I made my first successful ShExML, the generated RDF from a CSV file as a source. ''' PREFIX : https://www.example.org/donor/ PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#

SOURCE csv_file <2023_05_external_metadata.csv>

ITERATOR csv { FIELD id }

EXPRESSION donors

:donor :[donors.id] { rdf:type rdf:something ; } '''

However, to be consistent with ShEx, I was initially writing that as

''' PREFIX : https://www.example.org/donor/ PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#

SOURCE gbm_csv_file <2023_05_external_metadata.csv>

ITERATOR gbm_csv { FIELD id }

EXPRESSION donors

:donor :[donors.id] { rdf:type [rdf:something] ; } ''' Since the ShEx part in the first ShExML file would not parse for something to be rdf:something, but of type rdf:something.

herminiogg commented 1 year ago

Hi Andra,

Thanks for your comment regarding the ShExML syntax. Indeed, this is somewhat confusing as in ShExML the "[" and "]" symbols are used to enclose the expressions that need to be evaluated instead of describing the value sets. I know that coming from ShEx this can create some confusion, but value sets are not something that ShExML uses as the purpose of the language is totally different. Therefore, the square brackets notation was used for the evaluation of expressions as you need some syntax to tell the parser that this is in fact an expression that need to be evaluated, and this construction seemed to be the less intrusive one.

Nevertheless, it is worth noting that while ShExML is inspired by ShEx, it is a different language and therefore it has a different syntax adapted to the purpose of ShExML: generating RDF instead of validating it. Either way, based in these commonalities it is quite easy to generate a ShEx or SHACL file as you can try here: https://shexml.herminiogarcia.com/validation/shex.html.

Best, Herminio