. . . . "2017-06-13T05:41:53Z" . . . . . "d44486517f677929940cf4a0fba234b7" . . . . . "2017-06-13T05:41:53Z" . . . "2017-06-13T05:41:53.241480"^^ . "2017-06-13T05:41:53.241480"^^ . . . . . "VirtTipsAndTricksTransitivityInferenceLists" . "VirtTipsAndTricksTransitivityInferenceLists" . . . . "VirtTipsAndTricksTransitivityInferenceLists" . . . . . . . "%META:TOPICPARENT{name=\"VirtTipsAndTricksGuide\"}%\n\n---+How Do I use Transitivity via Inference Rules and Transitivity for lists?\n\nTwo methods can be used for typical recursions, transitivity on inference and plain transitive patterns (or subqueries).\n\nThe advantage of inference is that queries are short and one inference rule set may be maintained for numerous queries.\n\nIf queries are about trees of classes or properties, or about equivalences of nodes, consider using inference rule sets.\n\nTransitive patterns are inconvenient and may easily result in queries that runs too long or hard to debug, but they're unavoidable in traversing social networks or plain querying of RDF lists.\n\nSo consider a rule set, a handful of nodes with classes from the rule set and a couple of RDF Lisp-style lists defined on demo.openlinksw.com:\n\n\n\nSQL> SPARQL CLEAR GRAPH ;\ncallret-0\nVARCHAR\n_______________________________________________________________________________\n\nClear -- done\n\n1 Rows. -- 0 msec.\n\nSQL> TTLP (' @prefix rdf: . \n @prefix rdfs: . \n @prefix owl: . \n @prefix e: . \n e:c1 rdfs:subClassOf e:c1or2 . \n e:c2 rdfs:subClassOf e:c1or2 . \n e:c1-10 rdfs:subClassOf e:c1 . \n e:c1-20 rdfs:subClassOf e:c1 . \n e:c2-30 rdfs:subClassOf e:c2 . \n e:c2-40 rdfs:subClassOf e:c2 . \n ', 'http://example.com/2/owl', 'http://example.com/2/owl' );\n\nDone. -- 0 msec.\n\n\n\nYou can also use the SPARUL equivalent variant:\n\n\nSPARQL \nPREFIX rdf: \nPREFIX rdfs: \nPREFIX owl: \nPREFIX e: \n\nINSERT IN GRAPH \n {\n e:c1 rdfs:subClassOf e:c1or2 .\n e:c2 rdfs:subClassOf e:c1or2 .\n e:c1-10 rdfs:subClassOf e:c1 .\n e:c1-20 rdfs:subClassOf e:c1 .\n e:c2-30 rdfs:subClassOf e:c2 .\n e:c2-40 rdfs:subClassOf e:c2 .\n } ;\n\n\n\n\nDefine the inference rule:\n\n\n\nSQL> rdfs_rule_set ('http://example.com/2/owl', 'http://example.com/2/owl');\n\nDone. -- 0 msec.\n\nSQL> SPARQL CLEAR GRAPH ;\ncallret-0\nVARCHAR\n_______________________________________________________________________________\n\nClear -- done\n\n1 Rows. -- 0 msec.\n\nSQL> TTLP ('\n @prefix e: .\n @prefix rdf: .\n @prefix owl: .\n e:s1 a e:c1 ; e:p1 \"Value of p1 for s1\" .\n e:s2 a e:c2 ; e:p1 \"Value of p1 for s2\" .\n e:s1-10 a e:c1-10 ; e:p1 \"Value of p1 for s1-10\" .\n e:s1-20 a e:c1-20 ; e:p1 \"Value of p1 for s1-20\" .\n e:s2-30 a e:c2-30 ; e:p1 \"Value of p1 for s2-30\" .\n e:s2-40 a e:c2-40 ; e:p1 \"Value of p1 for s2-40\" .\n e:lists\n rdf:_1 ( e:list1-item1 e:list1-item2 e:list1-item3 ) ;\n rdf:_2 (\n [ e:p2 \"Value of p2 of item1 of list2\" ; e:p3 \"Value of p3 of item1 of list2\" ]\n [ e:p2 \"Value of p2 of item2 of list2\" ; e:p3 \"Value of p3 of item2 of list2\" ]\n [ e:p2 \"Value of p2 of item3 of list2\" ; e:p3 \"Value of p3 of item3 of list2\" ] ) .\n ', 'http://example.com/2/data', 'http://example.com/2/data' );\n\nDone. -- 0 msec.\n\n\n\nYou can also use the SPARUL equivalent variant:\n\n\n\nSPARQL \nPREFIX e: \nPREFIX rdf: \nPREFIX owl: \n\nINSERT IN GRAPH \n {\n e:s1 a e:c1 ; e:p1 \"Value of p1 for s1\" .\n e:s2 a e:c2 ; e:p1 \"Value of p1 for s2\" .\n e:s1-10 a e:c1-10 ; e:p1 \"Value of p1 for s1-10\" .\n e:s1-20 a e:c1-20 ; e:p1 \"Value of p1 for s1-20\" .\n e:s2-30 a e:c2-30 ; e:p1 \"Value of p1 for s2-30\" .\n e:s2-40 a e:c2-40 ; e:p1 \"Value of p1 for s2-40\" .\n e:lists\n rdf:_1 ( e:list1-item1 e:list1-item2 e:list1-item3 ) ;\n rdf:_2 (\n [ e:p2 \"Value of p2 of item1 of list2\" ; e:p3 \"Value of p3 of item1 of list2\" ]\n [ e:p2 \"Value of p2 of item2 of list2\" ; e:p3 \"Value of p3 of item2 of list2\" ]\n [ e:p2 \"Value of p2 of item3 of list2\" ; e:p3 \"Value of p3 of item3 of list2\" ] )\n };\n\n\n\nSPARQL DESCRIBE works fine with inference, deriving additional type information:\n\n\nDEFINE input:inference \nDESCRIBE \nFROM \n\nfmtaggret-\nLONG VARCHAR\n_______________________________________________________________________________\n\n@prefix rdf: .\n@prefix ns1: .\nns1:s1 rdf:type ns1:c1or2 ,\nns1:c1 ;\nns1:p1 \"Value of p1 for s1\" .\n\n1 Rows. -- 0 msec.\n\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E%0D%0ADESCRIBE+%3Chttp%3A%2F%2Fexample.com%2Fe%2Fs1%3E%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E&should-sponge=&format=application%2Frdf%2Bxml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E%0D%0ADESCRIBE+%3Chttp%3A%2F%2Fexample.com%2Fe%2Fs1%3E%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E&should-sponge=&format=application%2Frdf%2Bxml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\n\nDEFINE input:inference \nDESCRIBE \nFROM \nfmtaggret-\nLONG VARCHAR\n_______________________________________________________________________________\n\n@prefix rdf: .\n@prefix ns1: .\nns1:s2 rdf:type ns1:c1or2 ,\nns1:c2 ;\nns1:p1 \"Value of p1 for s2\" .\n\n1 Rows. -- 0 msec.\n\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E%0D%0ADESCRIBE+%3Chttp%3A%2F%2Fexample.com%2Fe%2Fs2%3E+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E&should-sponge=&format=application%2Frdf%2Bxml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E%0D%0ADESCRIBE+%3Chttp%3A%2F%2Fexample.com%2Fe%2Fs2%3E+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E&should-sponge=&format=application%2Frdf%2Bxml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\n\nQuerying is simple as well:\n\n\n\nSQL>SPARQL DEFINE input:inference \nPREFIX e:\nSELECT * \nFROM \nWHERE \n { \n ?s a e:c1or2 ; \n e:p1 ?o \n }\n \ns o\nVARCHAR VARCHAR\n___________________________\n\nhttp://example.com/e/s1 Value of p1 for s1\nhttp://example.com/e/s1-10 Value of p1 for s1-10\nhttp://example.com/e/s1-20 Value of p1 for s1-20\nhttp://example.com/e/s2-30 Value of p1 for s2-30\nhttp://example.com/e/s2-40 Value of p1 for s2-40\nhttp://example.com/e/s2 Value of p1 for s2\n\n6 Rows. -- 0 msec.\n\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E++%0D%0APREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+*+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E+%0D%0AWHERE+%0D%0A++%7B+%0D%0A++++%3Fs+a+e%3Ac1or2+%3B+%0D%0A++++++++++e%3Ap1+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E++%0D%0APREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+*+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E+%0D%0AWHERE+%0D%0A++%7B+%0D%0A++++%3Fs+a+e%3Ac1or2+%3B+%0D%0A++++++++++e%3Ap1+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\n\n\nSQL>SPARQL DEFINE input:inference \nPREFIX e:\nSELECT * FROM \nWHERE \n { \n ?s a e:c1 ; \n e:p1 ?o \n }\n \ns o\nVARCHAR VARCHAR\n___________________________\n\nhttp://example.com/e/s1 Value of p1 for s1\nhttp://example.com/e/s1-10 Value of p1 for s1-10\nhttp://example.com/e/s1-20 Value of p1 for s1-20\n\n3 Rows. -- 0 msec.\n\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E++%0D%0APREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+*+FROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B+%0D%0A++++%3Fs+a+e%3Ac1+%3B+%0D%0A+++++++e%3Ap1+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E++%0D%0APREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+*+FROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B+%0D%0A++++%3Fs+a+e%3Ac1+%3B+%0D%0A+++++++e%3Ap1+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\nHowever you should care about duplicates if both types and properties are queried: the join will result in all combinations of types and property values.\n\n\nSQL>SPARQL DEFINE input:inference \nPREFIX e:\nSELECT * FROM \nWHERE \n { \n ?s a ?t ; \n e:p1 ?o \n }\n \ns t o\nVARCHAR VARCHAR VARCHAR\n___________________________\n\nhttp://example.com/e/s1 http://example.com/e/c1 Value of p1 for s1\nhttp://example.com/e/s1 http://example.com/e/c1or2 Value of p1 for s1\nhttp://example.com/e/s1-10 http://example.com/e/c1-10 Value of p1 for s1-10\nhttp://example.com/e/s1-10 http://example.com/e/c1 Value of p1 for s1-10\nhttp://example.com/e/s1-10 http://example.com/e/c1or2 Value of p1 for s1-10\nhttp://example.com/e/s1-20 http://example.com/e/c1-20 Value of p1 for s1-20\nhttp://example.com/e/s1-20 http://example.com/e/c1 Value of p1 for s1-20\nhttp://example.com/e/s1-20 http://example.com/e/c1or2 Value of p1 for s1-20\nhttp://example.com/e/s2-30 http://example.com/e/c2-30 Value of p1 for s2-30\nhttp://example.com/e/s2-30 http://example.com/e/c2 Value of p1 for s2-30\nhttp://example.com/e/s2-30 http://example.com/e/c1or2 Value of p1 for s2-30\nhttp://example.com/e/s2-40 http://example.com/e/c2-40 Value of p1 for s2-40\nhttp://example.com/e/s2-40 http://example.com/e/c2 Value of p1 for s2-40\nhttp://example.com/e/s2-40 http://example.com/e/c1or2 Value of p1 for s2-40\nhttp://example.com/e/s2 http://example.com/e/c2 Value of p1 for s2\nhttp://example.com/e/s2 http://example.com/e/c1or2 Value of p1 for s2\n\n16 Rows. -- 0 msec.\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E++%0D%0APREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+*+FROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B+%0D%0A++++%3Fs+a+%3Ft+%3B+%0D%0A+++++e%3Ap1+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=DEFINE+input%3Ainference+%3Chttp%3A%2F%2Fexample.com%2F2%2Fowl%3E++%0D%0APREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+*+FROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B+%0D%0A++++%3Fs+a+%3Ft+%3B+%0D%0A+++++e%3Ap1+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\n\nTransitive queries are convenient as SPARQL 1.1 \"predicate+\" equivalent. The equivalent of \"predicate*\" requires the use of a union:\n\n\n\nSQL>SPARQL PREFIX e:\nSELECT ?item \nFROM \nWHERE \n {\n { \n ?lists rdf:_1 ?node \n }\n UNION\n { \n ?lists rdf:_1 ?l .\n ?l rdf:rest ?node option (transitive) . \n }\n ?node rdf:first ?item \n }\n \nitem\nVARCHAR\n_______________________________________________________________________________\n\nhttp://example.com/e/list1-item1\nhttp://example.com/e/list1-item2\nhttp://example.com/e/list1-item3\n\n3 Rows. -- 0 msec.\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=PREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+%3Fitem+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_1+%3Fnode+%0D%0A++++%7D%0D%0A++++UNION%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_1+%3Fl+.%0D%0A++++++%3Fl+rdf%3Arest+%3Fnode+option+%28transitive%29+.+%0D%0A++++%7D%0D%0A++++%3Fnode+rdf%3Afirst+%3Fitem+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=PREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+%3Fitem+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_1+%3Fnode+%0D%0A++++%7D%0D%0A++++UNION%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_1+%3Fl+.%0D%0A++++++%3Fl+rdf%3Arest+%3Fnode+option+%28transitive%29+.+%0D%0A++++%7D%0D%0A++++%3Fnode+rdf%3Afirst+%3Fitem+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\n\n\nSQL> SPARQL PREFIX e:\nSELECT ?p ?o \nFROM \nWHERE \n {\n { \n ?lists rdf:_2 ?node \n }\n UNION\n { \n ?lists rdf:_2 ?l .\n ?l rdf:rest ?node option (transitive) . \n }\n ?node rdf:first ?item .\n ?item ?p ?o \n }\n \np o\nVARCHAR VARCHAR\n________________________\n\nhttp://example.com/e/p2 Value of p2 of item1 of list2\nhttp://example.com/e/p3 Value of p3 of item1 of list2\nhttp://example.com/e/p2 Value of p2 of item2 of list2\nhttp://example.com/e/p3 Value of p3 of item2 of list2\nhttp://example.com/e/p2 Value of p2 of item3 of list2\nhttp://example.com/e/p3 Value of p3 of item3 of list2\n\n6 Rows. -- 0 msec.\n\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=PREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+%3Fp+%3Fo+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fnode+%0D%0A++++%7D%0D%0A++++UNION%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fl+.%0D%0A++++++%3Fl+rdf%3Arest+%3Fnode+option+%28transitive%29+.+%0D%0A++++%7D%0D%0A++++%3Fnode+rdf%3Afirst+%3Fitem+.%0D%0A++++%3Fitem+%3Fp+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=PREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+%3Fp+%3Fo+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fnode+%0D%0A++++%7D%0D%0A++++UNION%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fl+.%0D%0A++++++%3Fl+rdf%3Arest+%3Fnode+option+%28transitive%29+.+%0D%0A++++%7D%0D%0A++++%3Fnode+rdf%3Afirst+%3Fitem+.%0D%0A++++%3Fitem+%3Fp+%3Fo+%0D%0A++%7D&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\n\n\nNote that the result set can be in order of items in the list, but it don't have to. If the order should be preserved, then fix the direction of transitive scan, get step number as a variable, order by that variable.\n\n\n\nSQL> SPARQL PREFIX e:\nSELECT ?p ?o bif:coalesce(?step_no, 0) \nFROM \nWHERE \n {\n { \n ?lists rdf:_2 ?node \n }\n UNION\n { \n ?lists rdf:_2 ?l .\n ?l rdf:rest ?node OPTION (transitive, t_direction 1, t_step(\"step_no\") as ?step_no) . \n }\n ?node rdf:first ?item .\n ?item ?p ?o \n } \nORDER BY ASC (?step_no)\n\np o callret-2\nVARCHAR VARCHAR VARCHAR\n________________________\n\nhttp://example.com/e/p2 Value of p2 of item1 of list2 0\nhttp://example.com/e/p3 Value of p3 of item1 of list2 0\nhttp://example.com/e/p2 Value of p2 of item2 of list2 1\nhttp://example.com/e/p3 Value of p3 of item2 of list2 1\nhttp://example.com/e/p2 Value of p2 of item3 of list2 2\nhttp://example.com/e/p3 Value of p3 of item3 of list2 2\n\n6 Rows. -- 7 msec.\n\n\nExample links against [[http://demo.openlinksw.com/sparql][Virtuoso Demo Server SPARQL Endpoint]] with SPARQl Protocol URLs:\n\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&query=PREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+%3Fp+%3Fo+bif%3Acoalesce%28%3Fstep_no%2C+0%29+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fnode+%0D%0A++++%7D%0D%0A++++UNION%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fl+.%0D%0A++++++%3Fl+rdf%3Arest+%3Fnode+OPTION+%28transitive%2C+t_direction+1%2C+t_step%28%22step_no%22%29+as+%3Fstep_no%29+.+%0D%0A++++%7D%0D%0A++++%3Fnode+rdf%3Afirst+%3Fitem+.%0D%0A++++%3Fitem+%3Fp+%3Fo+%0D%0A++%7D+%0D%0AORDER+BY+ASC+%28%3Fstep_no%29%0D%0A&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View results page]]\n * [[http://demo.openlinksw.com/sparql?default-graph-uri=&qtxt=PREFIX+e%3A%3Chttp%3A%2F%2Fexample.com%2Fe%2F%3E%0D%0ASELECT+%3Fp+%3Fo+bif%3Acoalesce%28%3Fstep_no%2C+0%29+%0D%0AFROM+%3Chttp%3A%2F%2Fexample.com%2F2%2Fdata%3E++%0D%0AWHERE+%0D%0A++%7B%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fnode+%0D%0A++++%7D%0D%0A++++UNION%0D%0A++++%7B+%0D%0A++++++%3Flists+rdf%3A_2+%3Fl+.%0D%0A++++++%3Fl+rdf%3Arest+%3Fnode+OPTION+%28transitive%2C+t_direction+1%2C+t_step%28%22step_no%22%29+as+%3Fstep_no%29+.+%0D%0A++++%7D%0D%0A++++%3Fnode+rdf%3Afirst+%3Fitem+.%0D%0A++++%3Fitem+%3Fp+%3Fo+%0D%0A++%7D+%0D%0AORDER+BY+ASC+%28%3Fstep_no%29%0D%0A&should-sponge=&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=0&debug=on][View editor page]]\n\n\n\n\n---++Related\n\n * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]] \n * [[http://docs.openlinksw.com/virtuoso/rdfsparqlrule.html#rdfsparqlrulesubclassandsubprop][Virtuoso Documentation: Subclasses and Subproperties]]\n * [[VirtsubClassOfOrientedSubsumptionTransitiveOptions][Transitive SPARQL query options and Exploit Inference Rules Examples]]" . . . . . . .