[redland-dev] Querying a rdf:Seq

Marinaio di terra marinaioditerra at gmail.com
Sat Jun 4 17:23:37 BST 2005


Hi all,
I really don't understand how to get the listing of a rdf:Seq
maintaining the sequence order and using Sparql as query language.

For example, if I have some data like this:
<toy:Toy rdf:ID="BigBall">
  <toy:name>Big Ball</toy:name>
  <toy:version>2.0</toy:version>
  <toy:sequence>
    <rdf:Seq>
      <rdf:li rdf:nodeID="_1" />
      <rdf:li rdf:nodeID="_2" />
      <rdf:li rdf:nodeID="_3" />
      <rdf:li rdf:nodeID="_4" />
      <rdf:li rdf:nodeID="_5" />
    </rdf:Seq>
  </toy:sequence>
</toy:Toy>

<rdf:Description rdf:nodeID="_1">
  <toy:color>Red</toy:color>
</rdf:Description>

<rdf:Description rdf:nodeID="_2">
  <toy:color>Blue</toy:color>
</rdf:Description>

<rdf:Description rdf:nodeID="_3">
  <toy:color>Yellow</toy:color>
</rdf:Description>

<rdf:Description rdf:nodeID="_4">
  <toy:color>Orange</toy:color>
</rdf:Description>

<rdf:Description rdf:nodeID="_5">
  <toy:color>Green</toy:color>
</rdf:Description>

And I want to iterare the colors, how can I do?
I've tried with something like this:

q = RDF.Query("PREFIX toy: <http://www.example.org/toy-schema.rdf#> " +
              "SELECT ?color " +
              "WHERE " +
              "(<http://www.example.org/sample.rdf#BigBall> toy:sequence ?x)"+
              "(?x ?y ?z) " +
              "(?z toy:color ?color)",
              query_language='sparql')

but it doesn't maintain the order ot the sequence.

Where am I wrong?

Thanks, have a nice day.
Christian.


More information about the redland-dev mailing list