- From: David Pratt <fairwinds@eastlink.ca>
- Date: Thu, 08 Sep 2005 09:58:01 -0300
- To: semantic-web@w3.org
Hi. I am using python rdflib. I have contacted the author of the
software but no response to query of how to add lang attribute to
properties on adding data to store. Anyone with any experience with
rdflib to provide any pointers. There is an api but few examples and
googling very little by the way of discussions, lists etc for the
library or rdf xml in general. Anyone using rdflib that can give me a
hint.
An example of the library is below that came with the library. I am
assuming there is a way to specify the languages on a property or
literal so that when serialized with give me something like this for
example <foaf:nick xml:lang="en">donna</foaf:nick> and when converted
to raw triples with give me donna@en.
# Create a namespace object for the Friend of a friend namespace.
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
# Create an identifier to use as the subject for Donna.
donna = BNode()
# Add triples using store's add method.
store.add((donna, RDF.type, FOAF["Person"]))
store.add((donna, FOAF["nick"], Literal("donna")))
store.add((donna, FOAF["name"], Literal("Donna Fales")))
# Serialize the store as RDF/XML to the file foaf.rdf.
store.save("foaf.rdf", format="pretty-xml")
Serializing produces:
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:foaf='http://xmlns.com/foaf/0.1/'
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
>
<foaf:Person>
<foaf:name>Donna Fales</foaf:name>
<foaf:nick>donna</foaf:nick>
</foaf:Person>
</rdf:RDF>
Regards,
David
Received on Thursday, 8 September 2005 12:58:21 UTC