Hi,
There seems to be a little confusion here.
There are two mechanisms for representing ordered sequences of things in
RDF. There are containers which come in three flavours one of which
(rdf:Seq) is intended for ordered sequences:
https://www.w3.org/TR/rdf-mt/#Containers
There are also collections aka Lists:
https://www.w3.org/TR/rdf-mt/#collections
These are quite different both syntactically and semantically so you
need to be clear on which one you are trying to use. Then the
appropriate syntax and Jena API will follow.
On 03/04/18 14:04, Andreas Kahl wrote:
Hello everyone,
we have the requirement to preserve the order of umbel:isLike resources
and rdagr2:alternateIdentity literals in
https://data.rism.info/id/rismauthorities/pe30077074?format=rdf . To my
understanding, rdf:List would be a good choice. I followed the
recommendation at
http://patterns.dataincubator.org/book/ordered-list.html (data shortened
for brevity here):
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:nodeID="genid5">
<rdf:type
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:li
rdf:resource="http://digital.slub-dresden.de/id339704470"/>
<rdf:li
rdf:resource="http://digital.slub-dresden.de/id313540659"/>
<rdf:li
rdf:resource="http://digital.slub-dresden.de/id307035654"/>
</rdf:Description>
<rdf:Description
rdf:about="http://data.rism.info/id/rismauthorities/pe30077074">
<umbel:isLike xmlns:umbel="http://umbel.org/umbel#"
rdf:nodeID="genid5"/>
</rdf:Description>
</rdf:RDF>
This is not a list. You are using the syntax for Containers but trying
to give it a type of rdf:List. This will not generate a legal list.
Selecting this list via SimpleSelector and using Jena's RDFList fails
because no rdf:first & rdf:rest are found:
Correct, your data doesn't contain any lists.
The only way of getting RDFList to work is adding
rdf:parseType='Collection'
Correct, if you are using RDF/XML that's the way to generate lists.
However, you need to get the whole of the syntax right and you haven't
shown your modified example.
but then more Blank Nodes are created and
only one element is found in the iteration (and not necessarily the
first).
Sounds like you haven't got the rest of the syntax right. For an example
see:
https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-parsetype-Collection
Note that this doesn't use the rdf:li syntax, that's for Containers not
for Collections.
W3C's validator says, the above rdf:List is valid RDF/XML.
It may be valid RDF/XML and it may mention rdf:List but it is not valid
RDF/XML for a list :)
Should I use another Java interface in Jena for this? Or do I have to
implement the list with more low level Jena calls avoiding the RDFList
interface? (e.g. iterating the _1, _2, _3, ...-Predicates with Selectors
myself)
The _1, _2 ... predicates are for Containers not Collections.
I'd suggest picking which approach you want to use (ideally Lists but
your choice), generating test cases in Turtle (*much* easier syntax when
dealing with lists) and then use the corresponding Jena API (RDFList if
you use lists). If you need to use RDF/XML then let the tools generate
that for your from Turtle or from programmatic calls.
Dave
Thanks & Best Regards
Andreas
P.S. My Jena dependency and version currently used:
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena</artifactId>
<version>3.6.0</version>
<type>pom</type>
</dependency>