File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from io import StringIO
66from os .path import dirname , abspath
77from rdflib import Graph , Literal , URIRef
8+ from rdflib .graph import Seq
89from rdflib .namespace import XSD , RDF
910
1011import odml
@@ -274,9 +275,20 @@ def parse_property(self, prop_uri):
274275 elems = list (self .g .objects (subject = prop_uri , predicate = attr [1 ]))
275276 if attr [0 ] == "value" and len (elems ) > 0 :
276277 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.
277282 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+
280292 elif attr [0 ] == "id" :
281293 prop_attrs [attr [0 ]] = prop_uri .split ("#" , 1 )[1 ]
282294 else :
You can’t perform that action at this time.
0 commit comments