On 2/25/2015 16:36, Jack Hodges wrote:
Well, as a SPARQL query it (the suggested solution) worked perfectly, but when I put the same logic into a SPIN rule it didn't. Here is the context:

Sample list:

["TRANSDUCER"^^xsd:NMTOKEN, "PHYSICAL"^^xsd:NMTOKEN, "FUNCTION"^^xsd:NMTOKEN]


is what ?obj2 in the query below looks like (which is type rdf:List)


SPARQL query (works great):

*SELECT*?o

*WHERE*{

*?arg1* owl:equivalentClass ?obj .

?obj owl:oneOf ?obj2 .

?obj2 (rdf:rest)*/rdf:first ?o .

}


and ?o is then bound to 3 strings: TRANSDUCER, PHYSICAL, and FUNCTION.


If I put the same SPARQL query into a SPIN rule:


*SELECT*?o

*WHERE*{

*?arg1* owl:equivalentClass ?obj .

?obj owl:oneOf ?obj2 .

?obj2 (rdf:rest)*/rdf:first ?o .

}


and bind ?arg1 to the same object that I used in the SPARQL query, I get just TRANSDUCER as a result.


SPIN functions can only ever return one result, and in your example the ordering of those values is arbitrary. If you need a "function" that produces multiple results, use spin:MagicProperty instead. If you need a SPIN rule, convert this into a CONSTRUCT query.

On your second question, yes I am sure we have lots of experience building complex strings out of SPARQL data. But if the logic becomes really complex, then using something like SWP is often the best choice. There you can operate on auxiliary result sets, do if-then-else and loops like in a programming language. You can turn SWP snippets into SPARQL functions, as described here:

http://www.topquadrant.com/2013/06/18/defining-sparql-functions-with-swp/

HTH
Holger



Very confusing. And what I want to do with this list of strings is to create a formatted string out of their combination. At first I thought I might be able to use spit:convertSPINRDFtoString in the SPARQL to create a string of strings and then operate on the new string. That didn't work because, even though the object I gave it is rdf:List the function complained that I was trying to convert a non list to a list. Then I thought I might try ui:concat but since my SPIN function isn't working it is hard to test this.


Question 1: Does anyone know why my SPARQL doesn't work in the SPIN function above?


Question 2: Has anyone need to and figured out how to build a formatted string without some complicated logic?


Thank as usual for any pointers...


Jack


On Saturday, January 24, 2015 at 8:16:17 PM UTC-8, Jack Hodges wrote:

    Thank you Scott, did the trick perfectly.

    Jack

    On Monday, January 19, 2015 at 2:24:11 PM UTC-8, Scott Henninger
    wrote:

        Jack; No reason to use spif:split, given that the data is
        already in RDF. Something like the following should work:

        SELECT ?str
        WHERE
        {  ...
           ?s rdf:rest*/rdf:first ?o .
            BIND (xsd:string(?o) AS ?str)
        }

        The rdf:rest*/rdf:first idiom will de-construct the RDF list
        into elements.

        -- Scott

        Sent from my iPhone

        On Jan 19, 2015, at 3:00 PM, Jack Hodges <jhodg...@gmail.com>
        wrote:

        I have a list of xsd:NMTOKENs that I want to render (using
        SWP) in a table or chart. These items are in an
        owl:equivalentClass as owl:oneOf items (an enumerated type).
        I tried breaking them up with spif:split (oops, not a
        string), and spif:foreach but neither worked. Here is an
        example list:

        ["FOO"^^xsd:NMTOKEN,

        "BAR"^^xsd:NMTOKEN,

        "BAZ"^^xsd:NMTOKEN]


        With other ways of modeling enumerated types (e.g., by
        representing FOO as an instance) I can do this, but this
        modeling approach was used by someone else.


        Is there a way to de-list these items in a SPARQL query?


        Thanks,


        Jack

-- You received this message because you are subscribed to the
        Google Group "TopBraid Suite Users", the topics of which
        include Enterprise Vocabulary Network (EVN), Reference Data
        Manager (RDM), TopBraid Composer, TopBraid Live, TopBraid
        Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
        To post to this group, send email to topbrai...@googlegroups.com
        ---
        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 topbraid-user...@googlegroups.com.
        For more options, visit https://groups.google.com/d/optout
        <https://groups.google.com/d/optout>.

--
You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), Reference Data Manager (RDM), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
---
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 topbraid-users+unsubscr...@googlegroups.com <mailto:topbraid-users+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Group "TopBraid 
Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), 
Reference Data Manager (RDM), TopBraid Composer, TopBraid Live, TopBraid Insight, 
SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to