On 2022-03-16 2:55 am, 'Felix Sasaki' via TopBraid Suite Users wrote:
Hi Holger,

thanks, that is very helpful for me and for deciding how to move forward. One follow-up question: I would like to generate a complete SHACL query via Wikidata, see an example here
https://w.wiki/4xFv
in the example query, I don't create one RDF list, but several sh:in predicates. Would that work as well, for SHACL validation?

No, the values of sh:in are expected to be rdf:Lists, i.e. a single, closed list for all states in your example. If you want to have an extensible list of values, and you had control over the data, you could create a class such as schema:GermanState and just use sh:class to point at it.

Holger



Best,

Felix


On Monday, 14 March 2022 at 23:36:29 UTC+1 Holger Knublauch wrote:

    Hi Felix,

    constructing rdf:Lists from SPARQL is notoriously hard. We have a
    work-around "magic property" that works for some use cases but not
    others, but I mention it here:

    /**
    <span class="style1">tops:constructRDFList</span>
    <p>(Experimental) This function binds variables for constructing
    an RDF list.
    It can be best used in a CONSTRUCT query. It is an experimental
    function, so it may work
    only in certain cases.</p>
    <ul>
    <li><i>Syntax:</i> <span class="style1">(?list ?subList ?element
    ?rest) tops:constructRDFList (?s ?p ?o) .</span></li>
    <li><i>Description:</i> The function iterates through <span
    class="style1">?s ?p ?o</span> to
    bind variables for constructing a list. Currently, only one
    variable in <span class="style1">?s ?p ?o</span>
    should be unassigned, and the other two should be assigned. Also
    the property "rdf:type" should be used instead of "a".
    <span class="style1">?list</span> variable is used as the head
    of the list and stays constant throughout the iteration, <span
    class="style1">?subList</span>
    is used as the sub heads of the list and changes with each
    iteration, <span class="style1">?element</span>
    is the unbound variable in <span class="style1">?s ?p ?o</span>
    and changes with each iteration,
    and <span class="style1">?rest</span> is the bound <span
    class="style1">?subList</span> of the
    next iteration, which the current iteration points to.</li>
    <li><i>Example:</i> In the following query, <span
    class="style1">tops:constructRDFList</span> constructs
    an <span class="style1">owl:oneOf</span> list of colleges. Here is
    the query and its usage in kennedys ontology:</li>
    <pre>
    CONSTRUCT {
        kennedys:College owl:oneOf ?list .
        ?subList rdf:first ?element .
        ?subList rdf:rest ?rest .
    }
    WHERE {
          (?list ?subList ?element ?rest) tops:constructRDFList (?s
    rdf:type kennedys:College) .
    }
    </pre>
    </ul>

    <p><b>Known limitations:</b> Only one variable in <span
    class="style1">?s ?p ?o</span>
    should be unassigned, and the other two should be assigned. The
    property "rdf:type" should be used instead of "a" in the function.</p>
    */

    It depends on how the WHERE clause looks like whether this could
    be used in your scenario. The tops namespace is
    http://www.topbraid.org/tops

    But for complex tasks involving recursive data structures such as
    rdf:Lists you'll be better off using a generic scripting language
    such as TopBraid's ADS JavaScript support.

    Holger


    On 2022-03-15 1:17 am, 'Felix Sasaki' via TopBraid Suite Users wrote:
    This is rather a SPARQL question, but asking here since I have a
    SHACL use case.

    I want to generate the items in sh:in out of existing RDF data. I
    have a CONSTRUCT query that looks like below:

    CONSTRUCT {
    ex:fooShape a sh:PropertyShape;
    sh:path ex:foo
    sh:in @@@ .
    }
    WHERE
    {
    SELECT ?listItem WHERE {
    # Query that creates bindings for ?listItem
    }
    }

    How should the part @@@ be written so that the object of the
    predicate sh:in becomes an RDF list, filled with ?listItem?

    Best,

    Felix
-- You received this message because you are subscribed to the
    Google Groups "TopBraid Suite Users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected].
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/topbraid-users/CAL58czrLFr-496KOMKEMFoBj-Awh36XM-7QPtCMbjqRNMhkWOQ%40mail.gmail.com
    
<https://groups.google.com/d/msgid/topbraid-users/CAL58czrLFr-496KOMKEMFoBj-Awh36XM-7QPtCMbjqRNMhkWOQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/01dbca04-6b1f-4e96-89d5-aa085561de69n%40googlegroups.com <https://groups.google.com/d/msgid/topbraid-users/01dbca04-6b1f-4e96-89d5-aa085561de69n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "TopBraid 
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/ad382506-ef77-6591-93dc-0a82eef13d1c%40topquadrant.com.

Reply via email to