Hi all,
I suspect I have a deep misunderstanding of how SuRF (and/or RDF)
is supposed to work. I have created a minimal example that
illustrates my problem, and I hope that a kind soul reading this
can explain to me what is going wrong.
I am trying to parse the following instance data representing a
tree with a root and two nodes:
--------------------------------------------------
:Top
a proc:ProcedureDefinition;
rdfs:label "Top";
proc:step [ a proc:ProcedureCall;
proc:definition :Sub1;
];
proc:step [ a proc:ProcedureCall;
proc:definition :Sub2;
]
.
:Sub1
a proc:ProcedureDefinition;
rdfs:label "Sub1"
.
:Sub2
a proc:ProcedureDefinition;
rdfs:label "Sub2"
.
-----------------------------------------------------
All I want to do using SuRF is (a) find the top node, and (b)
print the labels of the children. (a) is no problem, (b) is
what's driving me insane
My Python program contains the following relevant code:
-------------------------------------------------------
ProcedureDefinition =
session.get_class(surf.ns.PROC['ProcedureDefinition'])
topdef = ProcedureDefinition.get_by(rdfs_label="Top").first()
print topdef.rdfs_label
step = topdef.proc_step.first
print step.rdfs_label
---------------------------------------------------------
The first rdfs:label print is fine: it prints out "Top", just as
I expect. The second print statement, where I am expecting it to
print out the label of whatever child node of my top instance
happened to be picked as 'first', instead prints out:
[rdflib.term.Literal(u'Top'), rdflib.term.Literal(u'Sub2'),
rdflib.term.Literal(u'Sub1')]
i.e. it's a list of *all* the labels associated with *any*
ProcedureDefinition in the store!
As I said: I don't understand at all why this is happening, and
I'd be enormously grateful for some assistance, either on why
it's not doing what I expect, but also on how I could change
things so that it does. If it helps, I've put the full files on
DropBox: <
http://dl.dropbox.com/u/31054689/min-test.tar.gz>
Regards, and many thanks in advance,
--
Leo