XBEL file of links generated from Akara content
RSS feed

Style

(Cookies required)
Powered by 4Suite

4RDF is a full-featured RDF processing , offering RDF/XML and NTriples parsing, multiple persistence mechanisms and query using Versa.

The main component of 4RDF is the RDF model object, which provides an API for RDF processing. The Model is a thin abstract layerand delegates many storage and access considerations to the driver. There are drivers for in-memory models or RDBMS and even MetaKit back-ends.

Here is a simple example of creating a module from an RDF/XML source and

from Ft.Rdf import Util
  
NSS = {'rdf': "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ,
         'dc': "http://purl.org/dc/elements/1.1/",
         'sy': "http://purl.org/rss/1.0/modules/syndication/",
         'rss': "http://purl.org/rss/1.0/",
         'vsort': "http://rdfinference.org/versa/0/2/sort/"
       }

RSS_URI = 'http://www.oreillynet.com/meerkat/?_fl=rss10&t=ALL&c=5209'
model, db = Util.DeserializeFromUri(RSS_URI)

#Very simple query.  No namespaces used
result1 = Util.VersaQuery("all()", model)
print result1

#More complex query: uses namespaces from source file (rdf, fam)
#And from Versa spec (vsort)
QUERY = "sortq(type(rss:item), '.-dc:date->*', vsort:string) - rss:title -> *"
result2 = Util.VersaQuery(QUERY, model, nsMap=NSS)
print result1

An example of the result2 value is:

>>> import pprint
>>> pprint.pprint(result2)
[u'New Expansion of Copyright',
 u'Anti-Trust Reloaded: Halloween X',
 u'The right to marry and the right to source code',
 u'CIO Magazine on "The Myths of Open Source"',
 u'Now If I Had To Pick A Spokesperson For Open Source...',
 u'SCO: The email/memo is real',
 u'About my weblog',
 u'About my web log',
 u'Microsoft Loves Linux',
 u"Streamingmedia.com: VCR's for Streaming",
 u'PHP Security at OSCON',
 u'Interesting Interview About Blackhat Culture',
 u'Wifi = Computer Telepathy',
 u'An Artificial Intelligence Thesis',
 u"The world's two worst variable names"]
>>>

You can use the function VersaDataToXml to create an XML representation of the Versa output. For example:

>>> print Util.VersaDataToXml(result2)
<List>
  <String>New Expansion of Copyright</String>
  <String>Anti-Trust Reloaded: Halloween X</String>
  <String>The right to marry and the right to source code</String>
  <String>CIO Magazine on &quot;The Myths of Open Source&quot;</String>
  <String>Now If I Had To Pick A Spokesperson For Open Source...</String>
  <String>SCO: The email/memo is real</String>
  <String>About my weblog</String>
  <String>About my web log</String>
  <String>Microsoft Loves Linux</String>
  <String>Streamingmedia.com: VCR's for Streaming</String>
  <String>PHP Security at OSCON</String>
  <String>Interesting Interview About Blackhat Culture</String>
  <String>Wifi = Computer Telepathy</String>
  <String>An Artificial Intelligence Thesis</String>
  <String>The world's two worst variable names</String>
</List>

>>>

Comments