File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 5
5
from io import StringIO
6
6
from os .path import dirname , abspath
7
7
from rdflib import Graph , Literal , URIRef
8
+ from rdflib .graph import Seq
8
9
from rdflib .namespace import XSD , RDF
9
10
10
11
import odml
@@ -274,9 +275,20 @@ def parse_property(self, prop_uri):
274
275
elems = list (self .g .objects (subject = prop_uri , predicate = attr [1 ]))
275
276
if attr [0 ] == "value" and len (elems ) > 0 :
276
277
prop_attrs [attr [0 ]] = []
278
+
279
+ # rdflib does not respect order with RDF.li items yet, see comment above
280
+ # support both RDF.li and rdf:_nnn for now.
281
+ # Remove rdf:_nnn once rdflib respects RDF.li order in an RDF.Seq obj.
277
282
values = list (self .g .objects (subject = elems [0 ], predicate = RDF .li ))
278
- for v in values :
279
- prop_attrs [attr [0 ]].append (v .toPython ())
283
+ if len (values ) > 0 :
284
+ for v in values :
285
+ prop_attrs [attr [0 ]].append (v .toPython ())
286
+ else :
287
+ # rdf:__nnn part
288
+ valseq = Seq (graph = self .g , subject = elems [0 ])
289
+ for seqitem in valseq :
290
+ prop_attrs [attr [0 ]].append (seqitem .toPython ())
291
+
280
292
elif attr [0 ] == "id" :
281
293
prop_attrs [attr [0 ]] = prop_uri .split ("#" , 1 )[1 ]
282
294
else :
You can’t perform that action at this time.
0 commit comments