- From: Tim McIver <tim@timmciver.com>
- Date: Tue, 14 Mar 2023 23:00:09 -0400
- To: public-sparql-dev@w3.org
- Message-ID: <6b13672c-710d-f981-d890-8ad0143f5490@timmciver.com>
Hello, I have some hand-crafted Turtle documents where I hard-coded URIs and I'm trying to write a SPARQL CONSTRUCT to convert objects to use a UUID. As an example, I have several graphs like: <person/john-doe> a schema:Person ; schema:gender schema:Male ; schema:familyName "Doe" ; schema:givenName "John" ; I'd like to convert <person/john-doe> to a URI containing a UUID. I've tried several variations of a SPARQL CONSTRUCT like the following: PREFIX schema:<https://schema.org/> CONSTRUCT { ?person a schema:Person ; schema:givenName ?firstName ; schema:familyName ?lastName ; schema:gender ?gender . } WHERE { SELECT ?person ?firstName ?lastName ?gender { BIND(UUID() AS ?person) ?p a schema:Person ; schema:givenName ?firstName ; schema:familyName ?lastName ; schema:gender ?gender . } } This appears to work if there is only one Person in the input document but it does not give the results I'm hoping for when there is more than one. An example of the output I see is when there is more than one Person: @prefix schema: . @prefix xsd: . <urn:uuid:feec8e22-f9bd-4853-9009-b19f679c43df> a schema:Person ; schema:familyName "Doe" ; schema:gender schema:Female , schema:Male ; schema:givenName "Jane" , "John" . To be clear my expectation in this case is to have two separate Person graphs, one for each of the input Persons. I found this post <https://www.michaeldebellis.com/post/refactor_iri_names_to_uuids> by Michael Debellis that shows a method of doing this but I have not tried this as I felt there may be a more straight-forward way than that described there. I'm fairly new to SPARQL so this is likely not a correct assumption but I wanted to ask here if there is a way to make my query work. At the very least can someone explain why it won't work? Thank you, Tim
Received on Wednesday, 15 March 2023 13:20:21 UTC