W3C home > Mailing lists > Public > semantic-web@w3.org > September 2005

Re: rdflib lang:xml attribute on properties

From: David Pratt <fairwinds@eastlink.ca>
Date: Thu, 08 Sep 2005 11:14:09 -0300
To: Daniel Krech <eikeon@eikeon.com>
Cc: semantic-web@w3.org
Message-id: <D2FB7398-2072-11DA-B91E-000A27B3B070@eastlink.ca>

Many thanks Daniel for your nice work.  This is super!

Regards,
David

On Thursday, September 8, 2005, at 10:24 AM, Daniel Krech wrote:

>
>
> On Sep 8, 2005, at 8:58 AM, David Pratt wrote:
>
>>
>> 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.
>
> Hi David, I've had my head down working on some other stuff since I 
> got your message yesterday... and hadn't got back far enough yet when 
> responding to emails this morning. Others on this list should be able 
> to help as well, but I'll attempt a quick answer now.
>
>> 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"]))
>
> Change:
>
>> store.add((donna, FOAF["nick"], Literal("donna")))
>
> to:
>
> store.add((donna, FOAF["nick"], Literal("donna", lang="en")))
>
>> 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>
>
> And instead of:
>
>>     <foaf:nick>donna</foaf:nick>
>
> you will get:
>
> <foaf:nick xml:lang="en">donna</foaf:nick>
>
>>   </foaf:Person>
>> </rdf:RDF>
>>
>> Regards,
>> David
>>
>
>
> Daniel Krech, http://eikeon.com/
>
>
>
Received on Thursday, 8 September 2005 14:15:15 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 07:41:47 UTC