Forgot the "reply-all"; sorry.
---------- Forwarded message ----------
From: Niklas Lindström <[EMAIL PROTECTED]>
Date: Jun 13, 2007 9:08 PM
Subject: Re: [rdflib-dev] n3 serialize
To: Jon Crump <[EMAIL PROTECTED]>
Hi Jon!
You need to turn the subject and predicate of the added tuple into
URIRef:s; thus:
store.add((URIRef(ENTRY + s), URIRef(JO + p.replace(' ',
'_')), Literal(o)))
will work. Furher I suggest that ENTRY and JO are Namespace instances; thus:
ENTRY = Namespace("tag:entry/")
JO = Namespace("tag:jo#")
, and then doing:
store.add((ENTRY[s], JO[p.replace(' ', '_')], Literal(o)))
does the trick.
This isn't obvious though, and has bitten me a couple of times. I
believe there used to be type-checking to prevent (or alleviate) this?
I suggest we consider having ``.add`` always turning subjects and
predicates into URIRef:s. And objects should further be asserted
``isinstance(object, Identifier)``.
Is there the theoretical possibility of having Literal:s in these
places (though seemingly unsound)? I hope not; but were it so, and
that would be a case against this, a counter-case would be e.g. an
optional ``autotype`` keyword param, defaulting to True.
Best regards,
Niklas Lindström
On 6/13/07, Jon Crump <[EMAIL PROTECTED]> wrote:
> I hope you will forgive a question from a naive user. I've been
> experimenting with rdflib and have succeeded in building a ConjuctiveGraph
> thus:
>
> for x in dlol:
> for (s, p, o) in x:
> if p == "Date": continue
> store.add((ENTRY + s, JO + p.replace(' ', '_'), Literal(o)))
> print store.serialize(format="pretty-xml")
>
> This successfully prints an rdf/xml serialization of my test graph but if
> I replace pretty-xml with n3, I get this error:
>
> AttributeError: 'unicode' object has no attribute 'n3'
>
> Perhaps there is something obvious I'm missing?
> _______________________________________________
> Dev mailing list
> [email protected]
> http://rdflib.net/mailman/listinfo/dev
>
_______________________________________________
Dev mailing list
[email protected]
http://rdflib.net/mailman/listinfo/dev