Hi Andy, Yes, it works now. Thank you very much for this.
Regards Yasir -----Original Message----- From: Andy Seaborne <[email protected]> Sent: 05 August 2021 21:30 To: [email protected] Subject: Re: SHACL-SPARQL Firstly -- here's the data (from your email that went the moderator): You've fixed the aso:GArent vs aso:User. ---------------------- @prefix rdf: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=VAdOlc%2F7n8VHOepYwCy68mGyg1GdmDWp7S6cIrvSbrU%3D&reserved=0> . @prefix sh: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2Fns%2Fshacl%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Ns9lOP2dYeJIJmWFh8pVsYul%2FiR%2BZkF6fxCfxwvkELM%3D&reserved=0> . @prefix xsd: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=49y6RKLtI6mNQ09oJ3%2BtQAkyRgqchw9vHfyqkNdSFmo%3D&reserved=0> . @prefix rdfs: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ftxsyPnc%2BqK7JAgQu0apnnX7VlG9IyNmlImna8sXXuY%3D&reserved=0> . @prefix ex: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.example.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=F9EYf4u7t7LCGT1CygP6qAvUZuwKUXUUMOZj8ytopow%3D&reserved=0> . @prefix aso: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.semanticweb.org%2Faso%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=hH7QZ6fiREkz197NqSpYEwuB3DGshIEx2%2BDPYMkGmNc%3D&reserved=0> . @prefix schema: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2FFve8VLBDm4IH4KAUZMksBWPBoj%2Fl%2FTphwu%2B64XzK%2F4%3D&reserved=0> . aso:alice a aso:User ; schema:givenName "Alice" ; schema:familyName "Cooper" ; schema:name "Alice Cooper" . aso:bob a aso:User ; schema:givenName "Bob" ; schema:familyName "Smith" ; schema:name "Robert Smith" . ---------------------- and shapes ---------------------- @prefix rdf: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=VAdOlc%2F7n8VHOepYwCy68mGyg1GdmDWp7S6cIrvSbrU%3D&reserved=0> . @prefix sh: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2Fns%2Fshacl%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Ns9lOP2dYeJIJmWFh8pVsYul%2FiR%2BZkF6fxCfxwvkELM%3D&reserved=0> . @prefix xsd: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=49y6RKLtI6mNQ09oJ3%2BtQAkyRgqchw9vHfyqkNdSFmo%3D&reserved=0> . @prefix rdfs: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ftxsyPnc%2BqK7JAgQu0apnnX7VlG9IyNmlImna8sXXuY%3D&reserved=0> . @prefix ex: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.example.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=F9EYf4u7t7LCGT1CygP6qAvUZuwKUXUUMOZj8ytopow%3D&reserved=0> . @prefix owl: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=YrPVDcXp17Oi0rswPmedFbIlgMYbZxRcnA5Ili4%2Fo%2Bo%3D&reserved=0> . @prefix aso: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.semanticweb.org%2Faso%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=hH7QZ6fiREkz197NqSpYEwuB3DGshIEx2%2BDPYMkGmNc%3D&reserved=0> . @prefix schema: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989080531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2FFve8VLBDm4IH4KAUZMksBWPBoj%2Fl%2FTphwu%2B64XzK%2F4%3D&reserved=0> . aso:UserShape a sh:NodeShape ; sh:targetClass aso:User ; sh:sparql [ a sh:SPARQLConstraint ; sh:message "schema:name must equal schema:givenName + schema:familyName"; sh:prefixes [ sh:declare [ sh:prefix "schema" ; sh:namespace "https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%2522%255E%255Exsd%3AanyURI&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=NoSZ1693cDiFtIEjj1WTUjCmbnoX913VY32zECVKZtU%3D&reserved=0 ; ] ] ; sh:select """SELECT $this (schema:name AS ?path) (?name as ?value) WHERE { $this schema:name ?name . $this schema:givenName ?givenName . $this schema:familyName ?familyName . FILTER (!isLiteral (?name) || !isLiteral (?givenName) || !isLiteral (?familyName) || concat( str(?givenName), ' ', str(?familyName)) !=?name) } """ ; ] . There are 2 problems: 1: The sh:namespace is wrong, missing a "#" "https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%23%2522%255E%255Exsd%3AanyURI&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Nbh0UdCb6dW14l%2F%2Br85qnch5PGzIJv9jFyCBJNOVQus%3D&reserved=0 2: The SPARQL query has an undefined usage: FILTER (!isLiteral (?name) but ?name isn't defined until SELECT (?name as ?value) making the filter false always Fixed version: @prefix rdf: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=N3VBEtBD2XBNuaDqknoFrrRbuGrNqfFjfY13cvCCLS4%3D&reserved=0> . @prefix sh: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2Fns%2Fshacl%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=18IJ1tDEqPzeJ79iDCq3WpFzE9BwK89wjUdsFbQ0%2B0o%3D&reserved=0> . @prefix xsd: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=C9d6fCfjs4vm%2F9hekS1ubVbmBoYar46NpG6D7whYPek%3D&reserved=0> . @prefix rdfs: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=35iiNe6jKoKysUA1tFfEwoMwwtn0328iOryHKy2ecfs%3D&reserved=0> . @prefix ex: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.example.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2FuzyPuRKMtmdMbWLx4DY3e5SQrvIxhiXsLhYMy3CrZA%3D&reserved=0> . @prefix owl: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=EMJPGLGbq2MAgmXar89h%2FCuXRXprIFRaWbL%2BmMrh47I%3D&reserved=0> . @prefix aso: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.semanticweb.org%2Faso%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Rm1iU08uXat6kUfkQtcpoj984GGt1ar5uiBqePRFnik%3D&reserved=0> . @prefix schema: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=nqqWrQlWp7%2F%2FfW3OXu7J13F5dYJqqx4GXyHmkW%2BySe4%3D&reserved=0> . aso:UserShape a sh:NodeShape ; sh:targetClass aso:User ; sh:sparql [ a sh:SPARQLConstraint ; sh:message "schema:name must equal schema:givenName + schema:familyName"; sh:prefixes [ sh:declare [ sh:prefix "schema" ; ##1 sh:namespace "https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%2522%255E%255Exsd%3AanyURI&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=NoSZ1693cDiFtIEjj1WTUjCmbnoX913VY32zECVKZtU%3D&reserved=0 ; sh:namespace "https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%23%2522%255E%255Exsd%3AanyURI&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Nbh0UdCb6dW14l%2F%2Br85qnch5PGzIJv9jFyCBJNOVQus%3D&reserved=0 ; ] ] ; sh:select ##2 FILTER """SELECT $this (schema:name AS ?path) (?name as ?value) WHERE { $this schema:name ?name . $this schema:givenName ?givenName . $this schema:familyName ?familyName . FILTER ( !isLiteral (?givenName) || !isLiteral (?familyName) || concat( str(?givenName), ' ', str(?familyName)) !=?name) } """ ; ] . gives: @prefix aso: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.semanticweb.org%2Faso%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Rm1iU08uXat6kUfkQtcpoj984GGt1ar5uiBqePRFnik%3D&reserved=0> . @prefix ex: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.example.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2FuzyPuRKMtmdMbWLx4DY3e5SQrvIxhiXsLhYMy3CrZA%3D&reserved=0> . @prefix owl: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=EMJPGLGbq2MAgmXar89h%2FCuXRXprIFRaWbL%2BmMrh47I%3D&reserved=0> . @prefix rdf: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=N3VBEtBD2XBNuaDqknoFrrRbuGrNqfFjfY13cvCCLS4%3D&reserved=0> . @prefix rdfs: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989090488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=35iiNe6jKoKysUA1tFfEwoMwwtn0328iOryHKy2ecfs%3D&reserved=0> . @prefix schema: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fschema.org%2F%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989100444%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=wE3Ok2Nm20qjMK7FzltTYddS%2FN8ZbMGacRg1wp9xq%2FU%3D&reserved=0> . @prefix sh: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2Fns%2Fshacl%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989100444%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=9ZgZ0NtR3w3xx0Q87dGDI1kSDd%2BMc2VEZ1cAlesFzXo%3D&reserved=0> . @prefix xsd: <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=04%7C01%7CY.Alani%40tees.ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C1%7C637637921989100444%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=SqJNa%2Fulk0QiuUmBId6MwrjPCkp9u0gO%2BWSjhCcG4T8%3D&reserved=0> . [ rdf:type sh:ValidationReport ; sh:conforms false ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode aso:bob ; sh:resultMessage "schema:name must equal schema:givenName + schema:familyName" ; sh:resultPath schema:name ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ; sh:sourceShape aso:UserShape ; sh:value "Robert Smith" ] ] . Andy On 05/08/2021 19:44, Alani, Yasir wrote: > Hello, > > > > Thank you for your previous email. > > > > I am trying to use SHACL-SPARQL to validate some data and it does not seem to > work as intended. I am trying to validate an example (shape and data) found > in the book "Validating RDF data". > > > > > > The shape is as follows: > > > > :UserShape a sh:NodeShape ; > > sh:targetClass :User ; //all instances of class user must conform to > the following SPARQL constraint > > sh:sparql [ > > a sh:SPARQLConstraint ; > > sh:message "schema:name must equal schema:givenName + > schema:familyName"; //this is what I would like the constraint to do > > sh:prefixes [ > > sh:declare [ > > sh:prefix "schema" ; > > sh:namespace > "https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsche > ma.org%2F%2522%255E%255Exsd%3AanyURI&data=04%7C01%7CY.Alani%40tees > .ac.uk%7C607386daff1d42443ee608d9584fc9ed%7C43d2115ba55e46b69df7b03388 > ecfc60%7C0%7C1%7C637637921989100444%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC > 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sd > ata=mrEQW0g4V2r%2BDS%2B6yY%2FHl3TLgwEoevajEuwnamZXg48%3D&reserved= > 0 ; > > ] > > ] ; > > sh:select""" > > SELECT $this (schema:name AS ?path) (?name as ?value) > > WHERE { > > $this schema:name ?name . > > $this schema:givenName ?givenName . > > $this schema:familyName ?familyName . > > FILTER (!isLiteral (?value) || > > !isLiteral (?givenName) || > > !isLiteral (?familyName) || > > concat( str(?givenName), ' ', str(?familyName)) !=?name > > ) > > }""" ; > > ] . > > > > > > The data graph is as follows: > > > > :Alice a :User ; > > schema:givenName "Alice" ; > > schema:familyName "Cooper" ; > > schema:name "Alice Cooper" . > > > > :Bob a :User ; > > schema:givenName "Bob" ; > > schema:familyName "Smith" ; > > schema:name "Robert Smith" . > > > > > > The Jena code is as follows: > > > > public class ValidationTest { > > > > public static void main(String[] args) { > > > > String SHAPE = "C:\\Users\\Test.txt" ; > > String DATA = "C:\\Users\\TestData.txt" ; > > > > Graph shapesGraph = > RDFDataMgr.loadGraph(SHAPE, Lang.TURTLE) ; > > Graph dataGraph = RDFDataMgr.loadGraph(DATA, > Lang.TURTLE) ; > > > > Shapes shapes = Shapes.parse(shapesGraph) ; > > > > ShaclValidator validator = > ShaclValidator.get() ; > > ValidationReport report = > validator.validate(shapesGraph, dataGraph) ; > > > > System.out.println() ; > > RDFDataMgr.write(System.out, > report.getModel(), Lang.TTL) ; > > } > > } > > > > The validation result is as follows: > > > > > > [ a sh:ValidationReport ; > > sh:conforms true > > ] . > > > > As you can see, one node should conform and one node should not, but this is > not what I am getting as a validation result. Please advise. > > > > Thank you very much > > Yasir > >
