<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ivan’s private site &#187; Code</title>
	<atom:link href="http://ivan-herman.name/category/work-related/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivan-herman.name</link>
	<description></description>
	<lastBuildDate>Thu, 26 Jan 2012 14:51:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ivan-herman.name' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/b36c82dd81cc7fc066d729227bbf8cba?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Ivan’s private site &#187; Code</title>
		<link>http://ivan-herman.name</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ivan-herman.name/osd.xml" title="Ivan’s private site" />
	<atom:link rel='hub' href='http://ivan-herman.name/?pushpress=hub'/>
		<item>
		<title>Where we are with RDFa 1.1?</title>
		<link>http://ivan-herman.name/2011/12/16/where-we-are-with-rdfa-1-1/</link>
		<comments>http://ivan-herman.name/2011/12/16/where-we-are-with-rdfa-1-1/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 11:48:46 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[RDFa]]></category>
		<category><![CDATA[RDFa 1.1 Lite]]></category>
		<category><![CDATA[Resource Description Framework]]></category>
		<category><![CDATA[schema.org]]></category>

		<guid isPermaLink="false">http://ivan-herman.name/?p=809</guid>
		<description><![CDATA[There has been a flurry of activities around RDFa 1.1 in the past few months. Although a number of blogs and news items have been published on the changes, all those have become “officialized” only the past few days with the publication of the latest drafts, as well as with the publication of RDFa 1.1 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=809&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">
<div class="wp-caption alignright" style="width: 130px"><a href="http://commons.wikipedia.org/wiki/File:Rdface.gif"><img class="zemanta-img-inserted zemanta-img-configured" title="English: RDFa Content Editor" src="http://upload.wikimedia.org/wikipedia/commons/4/48/Rdface.gif" alt="English: RDFa Content Editor" width="120" height="120" /></a><p class="wp-caption-text">Image via Wikipedia</p></div>
</div>
<p style="text-align:left;">There has been a flurry of activities around RDFa 1.1 in the past few months. Although a number of blogs and news items have been published on the changes, all those have become “officialized” only the past few days with the <a href="http://www.w3.org/blog/SW/2011/12/16/new-versions-of-rdfa-core-1-1-and-the-xhtmlrdfa-1-1-drafts/">publication of the latest drafts</a>, as well as with the <a href="http://www.w3.org/blog/SW/2011/12/09/rdfa-lite-1-1-draft-published-rdfa-1-1-primer-updated/">publication of RDFa 1.1 Lite</a>. It may be worth looking back at the past few months to have a clearer idea on what happened. I make references to a number of other blogs that were published in the past few months; the interested readers should consult those for details.</p>
<p style="text-align:left;">The latest official drafts for RDFa 1.1 were published in Spring 2011. However, lot has happened since. First of all, the <a href="http://www.w3.org/2010/02/rdfa/wiki/Main_Page">RDFWA Working Group</a>, working on this specification, has received a significant amount of comments. Some of those were rooted in implementations and the difficulties encountered therein; some came from potential authors who asked for further simplifications. Also, the announcement of <a href="http://schema.org">schema.org</a> had an important effect: indeed, this initiative drew attention on the importance of structured data in Web pages, which also raised further questions on the usability of RDFa for that usage pattern This came to the fore even more forcefully at the <a href="http://www.w3.org/QA/2011/09/impressions_on_the_schemaorg_w.html">workshop organized by the stakeholders of schema.org</a> in Mountain View. A new<a href="http://www.w3.org/wiki/Html-data-tf"> task force on the relationships of RDFa and microdata</a> has been set up at W3C; beyond looking at the relationship of these two syntaxes, that task force also raised a number of issues on RDFa 1.1. These issues have been, by and large, accepted and handled by the Working Group (and reflected in the new drafts).</p>
<p style="text-align:left;">What does this mean for the new drafts? The bottom line: there have been some fundamental changes in RDFa 1.1. For example, profiles, introduced in earlier releases of RDFa 1.1, have been removed due to implementation challenges; however, management of vocabularies have acquired an <em>optional</em> feature that helps vocabulary authors to “bind” their vocabularies to other vocabularies, without introducing an extra burden on authors (see<a href="http://www.w3.org/blog/SW/2011/09/19/recent-changes-in-rdfa-1-1/"> another blog</a> for more details). Another long-standing issue was whether RDFa should include a syntax for ordered lists; this has been done now (see the <a href="http://www.w3.org/blog/SW/2011/09/19/recent-changes-in-rdfa-1-1/">same blog</a> for further details).</p>
<p style="text-align:left;">A more recent important change concerns the usage of <code>@property</code> and <code>@rel</code>. Although usage of these attributes for RDF savy authors was never a real problem (the former is for the creation of literal objects, whereas the latter is for URI references), they have proven to be a major obstacle for ‘lambda’ HTML authors. This issue came up quite forcefully at the schema.org workshop in Mountain View, too. After a long technical discussion in the group, the new version reduces the usage difference between the two significantly. Essentially, if, on the same element, <code>@property</code> is present together with, say, <code>@href</code> or <code>@resource</code>, and <code>@rel</code> or <code>@rev</code> is <em>not</em> present, a URI reference is generated as an object of the triple. I.e., when used on a, say, <code>&lt;link&gt;</code> or <code>&lt;a&gt;</code> element, <code>@property</code>  behaves exactly like <code>@rel</code>. It turns out that this usage pattern is so widespread that it covers most of the important use cases for authors. The new version of the <a href="http://www.w3.org/TR/rdfa-primer/">RDFa 1.1 Primer</a> (as well as the <a href="http://www.w3.org/TR/2011/WD-rdfa-core-20111215/">RDFa 1.1 Core</a>, actually) has a number of examples that show these. There are also some other changes related to the behaviour of <code>@typeof</code> in relations to <code>@property</code>; please consult the specification for these.</p>
<p style="text-align:left;">The publication of <a href="http://www.w3.org/TR/rdfa-lite/">RDFa 1.1 Lite</a> was also a very important step. This defines a “sub-set” of the RDFa attributes that can serve as a guideline for HTML authors to express simple structured data in HTML without bothering about more complex features. This is the subset of RDFa that <a href="http://blog.schema.org/2011/11/using-rdfa-11-lite-with-schemaorg.html">schema.org will “accept”,</a>  as an alternative to the <a href="http://dev.w3.org/html5/md/">microdata</a>, as a possible syntax for schema.org vocabularies. (There are some examples on how some schema.org example look like in RDFa 1.1 Lite on a <a href="http://www.w3.org/QA/2011/11/schemaorg_and_rdfa_11_lite_how.html">different blog</a>.) In some sense, RDFa 1.1 Lite can be considered like the equivalent of microdata, except that it leaves the door open for more complex vocabulary usage, mixture with different vocabularies, etc. (The <a href="http://www.w3.org/wiki/Html-data-tf">HTML Task Force</a> will publish soon a more detailed comparison of the different syntaxes.)</p>
<p style="text-align:left;">So here is, roughly, where we are today. The recent publications by the W3C RDFWA Working Group have, as I said, ”officialized” all the changes that were discussed since spring. The group decided not to publish a Last Call Working Draft, because the last few weeks’ of work on the <a href="http://www.w3.org/wiki/Html-data-tf">HTML Task Force</a> may reveal some new requirements; if not, the last round of publications will follow soon.</p>
<p style="text-align:left;">And what about implementations? Well, <a href="http://www.w3.org/2007/08/pyRdfa/Shadow.html">my “shadow” implementation of the RDFa distiller</a> (which also includes a separate “<a href="http://www.w3.org/2007/08/pyRdfa/Validator.html">validator</a>” service) incorporates all the latest changes. I also added a new feature a few weeks ago, namely the possibility to <a href="http://www.w3.org/QA/2011/11/rdfa_11_meets_json-ld_in_the_d.html">serialize the output in JSON-LD</a> (although this has become outdated a few days ago, due to some <a href="http://json-ld.org/minutes/2011-12-13/">changes in JSON-LD</a>…). I am not sure of the exact status of Gregg Kellogg’s <a href="http://rdf.greggkellogg.net/distiller">RDF Distiller</a>, but, knowing him, it is either already in line with the latest drafts or it is only a matter of a few days to be so. And there are surely more around that I do not know about.</p>
<p style="text-align:left;">This last series of publications have provided a nice closure for a busy RDFa year. I guess the only thing now is to wish everyone a Merry Christmas, a peaceful and happy Hanukkah, or other festivities you honor at this time of the year.  In any case, a very happy New Year!</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="float:right;" src="http://img.zemanta.com/zemified_e.png?x-id=374ecad3-7da1-4de6-a4f1-d8d92bb1ba64" alt="Enhanced by Zemanta" /></a></div>
<br />Filed under: <a href='http://ivan-herman.name/category/work-related/code/python/'>Python</a>, <a href='http://ivan-herman.name/category/work-related/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/category/work-related/'>Work Related</a> Tagged: <a href='http://ivan-herman.name/tag/html/'>HTML</a>, <a href='http://ivan-herman.name/tag/html5/'>HTML5</a>, <a href='http://ivan-herman.name/tag/json/'>JSON</a>, <a href='http://ivan-herman.name/tag/rdfa/'>RDFa</a>, <a href='http://ivan-herman.name/tag/rdfa-1-1-lite/'>RDFa 1.1 Lite</a>, <a href='http://ivan-herman.name/tag/resource-description-framework/'>Resource Description Framework</a>, <a href='http://ivan-herman.name/tag/schema-org/'>schema.org</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/809/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/809/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/809/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/809/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/809/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/809/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/809/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/809/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/809/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/809/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/809/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/809/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/809/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/809/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=809&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2011/12/16/where-we-are-with-rdfa-1-1/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/commons/4/48/Rdface.gif" medium="image">
			<media:title type="html">English: RDFa Content Editor</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/zemified_e.png?x-id=374ecad3-7da1-4de6-a4f1-d8d92bb1ba64" medium="image">
			<media:title type="html">Enhanced by Zemanta</media:title>
		</media:content>
	</item>
		<item>
		<title>My first mapping from RDB to RDF using a direct mapping, cont.</title>
		<link>http://ivan-herman.name/2010/11/23/my-first-mapping-from-direct-mapping-cont/</link>
		<comments>http://ivan-herman.name/2010/11/23/my-first-mapping-from-direct-mapping-cont/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 19:29:31 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[R2RML]]></category>
		<category><![CDATA[Relational Database]]></category>
		<category><![CDATA[Resource Description Framework]]></category>
		<category><![CDATA[SPARQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://ivan-herman.name/?p=703</guid>
		<description><![CDATA[A few days ago I posted a blog on how the RDB to RDF direct mapping could be used for a simple example. I do not want to repeat the whole blog: the essence of it was that database tables were mapped onto a simple RDF Graph (this is what the direct mapping does) and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=703&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few days ago I <a href="http://ivan-herman.name/2010/11/19/my-first-mapping-from-direct-mapping/">posted a blog</a> on how the RDB to RDF direct mapping could be used for a simple example. I do not want to repeat the whole blog: the essence of it was that database tables were mapped onto a simple RDF Graph (this is what the direct mapping does) and the resulting graph was transformed into the “target” graph using the following SPARQL 1.1 construct:</p>
<pre>CONSTRUCT {
  ?id a:title ?title ;
    a:year  ?year ;
    a:author _:x .
  _:x a:name ?name ;
    a:homepage ?hp .
}
WHERE {
  SELECT (IRI(fn:concat("http://...",?isbn)) AS ?id)
          ?title ?year ?name
         (IRI(?homepage) AS ?hp)
  {
    ?book a  &lt;Book&gt;;
       ?isbn ;
       ?title ;
        ?year ;
       ?author .
    ?author a  &lt;Author&gt;;
       ?name ;
       ?homepage .
  }
}</pre>
<p>where the trick was to use a nested <code>SELECT</code> whose main job was to create URI references from strings. I realized that if one uses the latest editors’ version of SPARQL 1.1  (i.e., that version that is much closer to what SPARQL 1.1 will be) then the solution is actually simpler due to the variable assigning possibility that makes the nested <code>SELECT</code> unnecessary:</p>
<pre>CONSTRUCT {
  ?id a:title ?title ;
    a:year  ?year ;
    a:author _:x .
  _:x a:name ?name ;
    a:homepage ?hp .
}
WHERE {
  ?book a  &lt;Book&gt;;
     ?isbn ;
     ?title ;
      ?year ;
     ?author .
  ?author a  &lt;Author&gt;;
     ?name ;
     ?homepage .
  BIND (IRI(fn:concat("http://...",?isbn)) AS ?id)
  BIND (IRI(?homepage) AS ?hp)
}</pre>
<p>which makes, at least in my view, the mapping even clearer.</p>
<p>But SPARQL is not the only way to transform the graph. Another possibility is to use <a href="http://www.w3.org/TR/rif-overview/">RIF Core</a>. Essentially the same transformation can indeed be expressed using the RIF Presentation syntax. Here it is (with a little help from Sandro Hawke and Harold Boley):</p>
<pre>Forall ?book ?title ?author ?isbn ?year ?id (
  ?id[a:year-&gt;?year a:title-&gt;?title a:author-&gt;?author] :-
    And(
      ?book[rdf:type-&gt; &lt;Book&gt;
             a:isbn-&gt;?isbn
             a:title-&gt;?title
             a:year-&gt;?year
             a:author-&gt;?author]
      External(pred:iri-string(?id External( func:concat("http://..." ?isbn ) )))
    )
)
Forall ?author ?name ?hp ?homepage (
 ?author[a:name-&gt;?name a:homepage-&gt;?hp] :-
   And(
        ?author[rdf:type-&gt; &lt;Author&gt;
                a:name-&gt;?name
                a:homepage-&gt;?homepage]
        External(pred:iri-string(?hp ?homepage))
  )
)</pre>
<p>(as I did in the earlier examples, I did not put the prefix declaration and other syntactic stuffs into the code above.)</p>
<p>The only difference between the two is that I retained the URI for the author, because generating a blank node on the fly in RIF Core does not seem to be possible. A better solution would be, probably, to mint a URI from the ?<code>author</code> variable just like I did for the ISBN value. Other than that, the two solutions are pretty much identical…</p>
<br />Filed under: <a href='http://ivan-herman.name/category/work-related/code/'>Code</a>, <a href='http://ivan-herman.name/category/work-related/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/category/work-related/'>Work Related</a> Tagged: <a href='http://ivan-herman.name/tag/r2rml/'>R2RML</a>, <a href='http://ivan-herman.name/tag/relational-database/'>Relational Database</a>, <a href='http://ivan-herman.name/tag/resource-description-framework/'>Resource Description Framework</a>, <a href='http://ivan-herman.name/tag/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/tag/sparql/'>SPARQL</a>, <a href='http://ivan-herman.name/tag/sql/'>SQL</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/703/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/703/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/703/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/703/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/703/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/703/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/703/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=703&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2010/11/23/my-first-mapping-from-direct-mapping-cont/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>
	</item>
		<item>
		<title>My first mapping from RDB to RDF using a direct mapping</title>
		<link>http://ivan-herman.name/2010/11/19/my-first-mapping-from-direct-mapping/</link>
		<comments>http://ivan-herman.name/2010/11/19/my-first-mapping-from-direct-mapping/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 16:25:23 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[R2RML]]></category>
		<category><![CDATA[Relational Database]]></category>
		<category><![CDATA[Resource Description Framework]]></category>
		<category><![CDATA[SPARQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://ivan-herman.name/?p=696</guid>
		<description><![CDATA[A few weeks ago I wrote a blog on my first RDB to RDF mapping using R2RML; the W3C RDB2RDF Working Group had just published a first public Working Draft for R2RML. That mapping was based on a specific mapping language (i.e., R2RML). R2RML relies on an R2RML processing done by, for example, the database [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=696&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote a <a href="http://ivan-herman.name/2010/11/02/my-first-mapping-from-rdb-to-rdf-using-r2rml/">blog on my first RDB to RDF mapping using R2RML</a>; the W3C <a href="http://www.w3.org/2001/sw/rdb2rdf/">RDB2RDF Working Group</a> had just published a first public Working Draft for <a href="http://www.w3.org/TR/2010/WD-r2rml-20101028/">R2RML</a>. That mapping was based on a specific mapping language (i.e., R2RML). R2RML relies on an R2RML processing done by, for example, the database system, interpreting the language, using some SQL constructions, etc. The R2RML processing depends on the specific schema of the database which guides the mapping.</p>
<p>As I already mentioned in that blog, a “direct” mapping was also in preparation by the Working Group; well, the <a href="http://www.w3.org/TR/2010/WD-rdb-direct-mapping-20101118/">first public Working Draft</a> of that mapping has just been published. That mapping does not depend on the schema of the database: it defines a general mapping of <em>any</em> relational database structure into RDF; only a base URI has to be specified for the database, everything else is generated automatically. The resulting RDF graph is of course much more coarse than the one generated by R2RML; whereas the result of an R2RML mapping may be a graph using well specified vocabularies, for example, this is not the case for the output of the direct mapping. But that is not really a problem: after all, we have <a href="http://www.w3.org/TR/sparql11-query/">SPARQL</a> or <a href="http://www.w3.org/TR/rif-overview/">RIF</a> to make transformation on graphs! Ie, the two approaches are really complementary. </p>
<p>What I will do in this blog is to show how the very same example as in my <a href="http://ivan-herman.name/2010/11/02/my-first-mapping-from-rdb-to-rdf-using-r2rml/">previous blog</a> can be handled by a direct mapping. As a reminder: the toy example I use comes from my  generic Semantic Web tutorial. Here is the (toy) table:</p>
<p><img class="aligncenter" title="Imaginary bookshop table" src="http://www.ivan-herman.net/Misc/2010/blog/book_table.png" alt="" width="567" height="250" /></p>
<p>which is then converted into an RDF Graph:</p>
<p><img class="aligncenter" title="Graph of the bookshop example" src="http://www.ivan-herman.net/Misc/2010/blog/book_graph.png" alt="" width="571" height="317" /></p>
<p>(Just as in the previous case I will ignore the part of the graph dealing with the publisher, which has the same structure as the author part. I will also ignore the prefix definitions.)</p>
<p>The <a href="http://www.w3.org/TR/2010/WD-rdb-direct-mapping-20101118/">direct mapping</a> of the first and second tables is pretty straightforward. The URI-s are a bit ugly but, well, this is what you get when you use a generic solution. So here it is:</p>
<pre>@base &lt;http://book.example/&gt; .
&lt;Book/ID=0006511409X#_&gt; a &lt;Book&gt; ;
  &lt;Book#ISBN&gt; "0006511409X" ;
  &lt;Book#Title&gt; "The Glass Palace" ;
  &lt;Book#Year&gt;  "2000" ;
  &lt;Book#Author&gt; &lt;Author/ID=id_xyz#_&gt; .

&lt;Author/ID=id_xyz#_&gt; a &lt;Author&gt; ;
  &lt;Author#ID&gt; "id_xyz" ;
  &lt;Author#Name&gt; "Ghosh, Amitav" ;
  &lt;Author#Homepage&gt; "http://www.amitavghosh.com" .</pre>
<p>Simple, isn’t it? </p>
<p>The result is fairly close to what we want, but not exactly. First of all, we want to use different vocabulary terms (like <code>a:name</code>). Also, note that the direct mapping produces literal objects most of the time, except when there is a “jump” from one table to another. Finally, the resulting graph should use a blank node for the author, which is not the case in the generated graph.</p>
<p>Fortunately, we have tools in the Semantic Web domain to transform RDF graphs. RIF is one possible solution; another is SPARQL, using the <code>CONSTRUCT</code> form. Using SPARQL is an attractive solution because, in practice, the output of the direct mapping may not even be materialized; instead, one would expect a SPARQL engine attached to a particular relational database, mapping the SPARQL queries to the table on the fly. I will use SPARQL 1.1 below because that gives nice facilities to generate RDF URI Resources from strings, i.e., to have “bridges” from literals to URI-s. Here is a possible SPARQL 1.1 query/construct that could be used to achieve what we want:</p>
<pre>CONSTRUCT {
  ?id a:title ?title ;
    a:year  ?year ;
    a:author _:x .
  _:x a:name ?name ;
    a:homepage ?hp .
}
WHERE {
  SELECT (IRI(fn:concat("http://...",?isbn)) AS ?id)
          ?title ?year ?name
         (IRI(?homepage) AS ?hp)
  {
    ?book a &lt;Book&gt; ;
      &lt;Book#ISBN&gt; ?isbn ;
      &lt;Book#Title&gt; ?title ;
      &lt;Book#Year&gt;  ?year ;
      &lt;Book#Author&gt; ?author .
    ?author a &lt;Author&gt; ;
      &lt;Author#Name&gt; ?name ;
      &lt;Author#Homepage ?homepage .
  }
}</pre>
<p>Note the usage of a nested query; this is used to create new variables representing the URI references to be used by the outer query. The key is the <code>IRI</code> operator. (Both the nesting and the <code>AS</code> in the <code>SELECT</code> are SPARQL 1.1 features.)</p>
<p>That is it. Of course, the question does arise: which one would one use? The direct mapping or R2RML? Apart from the possible restriction that the local database system may implement the direct mapping only, it becomes also a question of taste. The heavy tool in R2RML is, in fact, the embedded SQL query; if one is comfortable with SQL than that is fine. But if the user is more comfortable with Semantic Web tools (e.g., SPARQL or RIF) then the direct mapping might be handier.</p>
<p>(Note that these are evolving documents still. I already know that my previous blog is wrong in the sense that it is not in line with the next version of R2RML. Oh well…)</p>
<br />Filed under: <a href='http://ivan-herman.name/category/work-related/code/'>Code</a>, <a href='http://ivan-herman.name/category/work-related/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/category/work-related/'>Work Related</a> Tagged: <a href='http://ivan-herman.name/tag/r2rml/'>R2RML</a>, <a href='http://ivan-herman.name/tag/relational-database/'>Relational Database</a>, <a href='http://ivan-herman.name/tag/resource-description-framework/'>Resource Description Framework</a>, <a href='http://ivan-herman.name/tag/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/tag/sparql/'>SPARQL</a>, <a href='http://ivan-herman.name/tag/sql/'>SQL</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/696/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/696/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/696/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/696/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/696/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/696/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/696/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=696&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2010/11/19/my-first-mapping-from-direct-mapping/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>

		<media:content url="http://www.ivan-herman.net/Misc/2010/blog/book_table.png" medium="image">
			<media:title type="html">Imaginary bookshop table</media:title>
		</media:content>

		<media:content url="http://www.ivan-herman.net/Misc/2010/blog/book_graph.png" medium="image">
			<media:title type="html">Graph of the bookshop example</media:title>
		</media:content>
	</item>
		<item>
		<title>My first mapping from RDB to RDF using R2RML</title>
		<link>http://ivan-herman.name/2010/11/02/my-first-mapping-from-rdb-to-rdf-using-r2rml/</link>
		<comments>http://ivan-herman.name/2010/11/02/my-first-mapping-from-rdb-to-rdf-using-r2rml/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 15:48:09 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[R2RML]]></category>
		<category><![CDATA[Relational Database]]></category>
		<category><![CDATA[Resource Description Framework]]></category>
		<category><![CDATA[SPARQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://ivan-herman.name/?p=677</guid>
		<description><![CDATA[The W3C RDB2RDF Working Group has just published a first public Working Draft for the standardized RDB-&#62;RDF mapping language called R2RML. I decided that the only way to understand a specification like that is to try to use it for an example. Caveat: this is a “First Public Working Draft” for R2RML, so many things [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=677&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The W3C <a href="http://www.w3.org/2001/sw/rdb2rdf/">RDB2RDF Working Group</a> has just published a first public Working Draft for the standardized RDB-&gt;RDF mapping language called <a href="http://www.w3.org/TR/2010/WD-r2rml-20101028/">R2RML</a>. I decided that the only way to understand a specification like that is to try to use it for an example. Caveat: this is a “First Public Working Draft” for R2RML, so many things still have to happen and there will be changes.</p>
<p>For several years now I use a simple example in my generic Semantic Web tutorial (see, e.g., the<a href="http://www.w3.org/2010/Talks/0622-SemTech-IH/"> one at SemTech</a>). It is an artificial example referring to an imaginary bookshop’s table:</p>
<p><img class="aligncenter" title="Imaginary bookshop table" src="http://www.ivan-herman.net/Misc/2010/blog/book_table.png" alt="" width="567" height="250" /></p>
<p>which is then converted into an RDF Graph:</p>
<p><img class="aligncenter" title="Graph of the bookshop example" src="http://www.ivan-herman.net/Misc/2010/blog/book_graph.png" alt="" width="571" height="317" /></p>
<p>(And the tutorial story is how this graph can be merged with a graph coming from another bookshop’s data.) Up until now I always glossed over how this mapping is done. Well, so how could that be done with R2RML?</p>
<p>R2RML defines mappings that describe how an RDB table is mapped on triples. (R2RML is in itself in RDF, b.t.w.) Simply put, in R2RML, each row of a table is mapped to an RDF subject; the individual cells, with the column names, provide the object and the predicates, respectively.</p>
<p>If we look at the middle table in the example, it corresponds to the lower right hand part of the graph. The R2RML mapping has to specify that the homepage column should actually produce an RDF Resource as a literal and not a string. Furthermore, the first column should become a blank node; that has to be specified, too. Here is the way this is all specified:</p>
<pre>:Table2 rdf:type rr:TriplesMap ;
    rr:logicalTable "Select  ("_:" || ID) AS pid, Name, ("&lt;" || Homepage || "&gt;) AS Home from person_table";
    rr:subjectMap [ a rr:BlankNodeMap ; rr:column "pid" ; ] ;
    rr:propertyObjectMap [ rr:property a:name; rr:column "Name" ] ;
    rr:propertyObjectMap [ a rr:IRIMap ; rr:property a:homepage; rr:column "Home" ] .</pre>
<p>What happens here is:</p>
<ol>
<li>a mapping is defined that turns the original table into a virtual, “logical” table using SQL. The goal here is to generate a blank node ID on the fly, and a URI in NTriple syntax (note, however, that <a href="http://lists.w3.org/Archives/Public/public-rdb2rdf-comments/2010Nov/0005.html">I am not sure it is o.k.</a> to use that approach in the spec!);</li>
<li>the subject for the triples is chosen to be a cell in a specific column (“pid”, generated by the SQL transform of the previous point), and it is also specified that this is a blank node;</li>
<li>the other two properties are specified (for the same subject); the one for the home page also specifies that the object must be a URI resource (as opposed to a Literal).</li>
</ol>
<p>That is it. Mapping of the bottom table to the lower left hand corner of the graph is also quite similar, I will not go into this here.</p>
<p>But we still need the “root”, so to say, i.e., the node in the upper right hand corner, the top portion of the graph (with the title and the year) and, mainly, we also have to relate the root to the portion of the graph that is generated from the middle table.</p>
<p>First, the following R2RML part does the job of generating the top part of the graph:</p>
<pre>:Table1 rdf:type rr:TriplesMap ;
    rr:logicalTable "Select ('&lt;http:..isbn/' || ISBN || '&gt;') AS isbn,
                     Author, Title, Publisher, Year from book_table";
    rr:subjectMap [ rdf:type rr:IRIMap ; rr:column "isbn" ] ;
    rr:propertyObjectMap [ rr:property a:title ; rr:column "Title" ; ] ;
    rr:propertyObjectMap [ rr:property a:year ; rr:column "Year" ; ] ;</pre>
<p>The only role of the mapping to a logical table is to generate a URI from the ISBN; all the other cells are, conceptually, simply copied on the logical table. The rest is fairly straightforward.</p>
<p>The missing trick is to combine, i.e., to “join”, the two tables on the graph. R2RML has a separate construction for that, referred to as “mapping” the foreign keys. The following additional statements should be added to <code>:Table1</code>:</p>
<pre>    rr:foreignKeyMap [
       rr:key a:author ;
       rr:parentTriplesMap :Table2 ; rr:joinCondition "{child}.Author = {parent}.pid"
    ] .</pre>
<p>Which combines the nodes defined by <code>:Table1</code> with those of <code>:Table2</code>. And voilà! We’re done: the R2RML document is ready, i.e., an R2RML engine would generate my example table into my example graph.</p>
<p>Of course, there are more complicated possibilities. Triples, or whole rows, can be explicitly stored in a specific named graph, for example. Or a column defining a predicate could, actually, use a cell in <em>another</em> column as an object. Etc. And, to be honest, I am not even 100% sure that above is correct, I may have misunderstood some details. But the “melody” is still clear.</p>
<p>Note the role the SQL based mapping of the original table to the logical table has. For SQL experts, most of the work can be done there, i.e., the resulting RDF graph can be ready for further usage by an application, to be linked into the LOD, to be used with the right attributes, namespaces, etc. Which is very powerful indeed, provided… the user has the necessary SQL expertise. And, while that is obviously true for database managers, it is not necessarily true for RDF experts. For those, a slightly different model seems to be more appropriate: they would prefer to get an RDF graph ASAP, so to say, without any fancy transformation, and would then use RIF, SWSRL, SPARQL’s CONSTRUCT, etc., to turn it into the RDF graph they eventually want to have. In other words, they may not need the concept of a logical table. That is what is referred to by the group as the “default” mapping. I.e., what graph does one get if nothing is specified? If that is properly defined then, say, RIF experts can use their expertise instead of SQL. This default mapping is not yet fully specified by the group, but it is on its way; it will be published shortly, and will complete the R2RML picture. So watch that space…</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=f4fb7e44-5b05-48c0-baae-19118d5add7d" alt="" /></div>
<br />Filed under: <a href='http://ivan-herman.name/category/work-related/code/'>Code</a>, <a href='http://ivan-herman.name/category/work-related/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/category/work-related/'>Work Related</a> Tagged: <a href='http://ivan-herman.name/tag/r2rml/'>R2RML</a>, <a href='http://ivan-herman.name/tag/relational-database/'>Relational Database</a>, <a href='http://ivan-herman.name/tag/resource-description-framework/'>Resource Description Framework</a>, <a href='http://ivan-herman.name/tag/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/tag/sparql/'>SPARQL</a>, <a href='http://ivan-herman.name/tag/sql/'>SQL</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/677/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=677&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2010/11/02/my-first-mapping-from-rdb-to-rdf-using-r2rml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>

		<media:content url="http://www.ivan-herman.net/Misc/2010/blog/book_table.png" medium="image">
			<media:title type="html">Imaginary bookshop table</media:title>
		</media:content>

		<media:content url="http://www.ivan-herman.net/Misc/2010/blog/book_graph.png" medium="image">
			<media:title type="html">Graph of the bookshop example</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/pixy.gif?x-id=f4fb7e44-5b05-48c0-baae-19118d5add7d" medium="image" />
	</item>
		<item>
		<title>Publication of the Last Call for RDFa Core 1.1</title>
		<link>http://ivan-herman.name/2010/10/27/publication-of-the-last-call-for-rdfa-core-1-1/</link>
		<comments>http://ivan-herman.name/2010/10/27/publication-of-the-last-call-for-rdfa-core-1-1/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 10:29:22 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[RDFa]]></category>
		<category><![CDATA[W3C recommendation]]></category>
		<category><![CDATA[World Wide Web Consortium]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://ivan-herman.name/?p=671</guid>
		<description><![CDATA[The W3C RDFa Working Group has just published the “Last Call Working Draft” for RDFa Core 1.1. As Manu Sporny, the co-chair of the group, said in his tweet, this W3C jargon is equivalent to a “feature freeze”. Ie, the group does not know of any outstanding technical issues and of missing features that it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=671&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.w3.org/2010/02/rdfa">W3C RDFa Working Group</a> has just published the “Last Call Working Draft” for RDFa Core 1.1. As Manu Sporny, the co-chair of the group, said in his tweet, this W3C jargon is equivalent to a “feature freeze”. Ie, the group does not know of any outstanding technical issues and of missing features that it would reasonably plan to add. Put it another way, this is last round of commenting before proceeding to final implementation testing and, hopefully, to a final W3C Standard. I.e., Last Call doesn’t mean that the group takes no more comments; on the contrary, technical comments are very welcome and necessary to make it sure that the final outcome is correct. Please, send your comments to the groups mailing list: <a href="mailto:public-rdfa-wg@w3.org">public-rdfa-wg@w3.org</a> (there is also a <a href="http://lists.w3.org/Archives/Public/public-rdfa-wg/">public archive</a>).</p>
<p>Although lots of things have been discussed in the past few months (i.e., since the <a href="http://www.w3.org/TR/2010/WD-rdfa-core-20100803/">last draft published in August</a>) not many things have significantly changed, in fact. Most of the changes are editorial, making the text clearer, more precise, etc. (You can look at the <a href="http://www.w3.org/TR/rdfa-core/rdfa-core-diff.html">“diff” file</a>, if you are interested.) This document is for the Core, i.e., the generic RDFa processing that can be used for any DOM. It is to be expected to have, in a few days, a similar document published for XHTML+RDFa 1.1 by the same Working Group, and an HTML5+RDFa 1.1 by the HTML Working Group.</p>
<p>I have also worked, in parallel to the specification work, on a modified version of the RDFa distiller. While the <a href="http://www.w3.org/2007/08/pyRdfa/">“official” service</a> remains unchanged and relies on the current RDFa Recommendation, there is now a <a href="http://www.w3.org/2007/08/pyRdfa/Shadow.html">“Shadow” version</a>, that relies on RDFa 1.1. The underlying code has undergone some cleanups beyond the adaptation to RDFa 1.1 so I am sure there are bugs…</p>
<p>Finally, a blatant self-promotion: Stéphane Corlosquet, Lin Clark and I will give a <a href="http://www.w3.org/2010/Talks/RDFa-Drupal-Tutorial/">tutorial</a> at the upcoming <a href="http://iswc2010.semanticweb.org/">ISWC conference</a> in Shanghai on RDFa and Drupal. The RDFa part relies on 1.1… (There are links to the slides on the page but you do not expect us <em>not</em> to touch them any more before the tutorial itself, do you? So make sure you look at them again <em>after</em> the event…)</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=3d5664fc-bbcc-498f-8d4a-f231728d2a1b" alt="" /></div>
<br />Filed under: <a href='http://ivan-herman.name/category/work-related/code/'>Code</a>, <a href='http://ivan-herman.name/category/work-related/code/python/'>Python</a>, <a href='http://ivan-herman.name/category/work-related/semantic-web/'>Semantic Web</a>, <a href='http://ivan-herman.name/category/work-related/'>Work Related</a> Tagged: <a href='http://ivan-herman.name/tag/html/'>HTML</a>, <a href='http://ivan-herman.name/tag/rdfa/'>RDFa</a>, <a href='http://ivan-herman.name/tag/w3c-recommendation/'>W3C recommendation</a>, <a href='http://ivan-herman.name/tag/world-wide-web-consortium/'>World Wide Web Consortium</a>, <a href='http://ivan-herman.name/tag/xhtml/'>XHTML</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/671/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/671/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/671/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/671/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/671/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/671/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/671/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/671/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/671/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/671/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/671/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/671/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/671/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/671/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=671&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2010/10/27/publication-of-the-last-call-for-rdfa-core-1-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/pixy.gif?x-id=3d5664fc-bbcc-498f-8d4a-f231728d2a1b" medium="image" />
	</item>
		<item>
		<title>OWL 2 RL closure</title>
		<link>http://ivan-herman.name/2009/09/29/owl-2-rl-closure/</link>
		<comments>http://ivan-herman.name/2009/09/29/owl-2-rl-closure/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 15:34:11 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[Description logic]]></category>
		<category><![CDATA[Knowledge Representation]]></category>
		<category><![CDATA[OWL]]></category>
		<category><![CDATA[OWL RL]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[RDFLib]]></category>
		<category><![CDATA[Resource Description Framework]]></category>
		<category><![CDATA[SPARQL]]></category>
		<category><![CDATA[w3c]]></category>

		<guid isPermaLink="false">http://ivan-herman.name/?p=397</guid>
		<description><![CDATA[OWL 2 has just been published as a Proposed Recommendation (yay!) which means, in laymen’s term, that the technical work is done, and it is up to the membership of W3C to accept it as a full blown Recommendation. As I already blogged before, I did some implementation work on a specific piece of OWL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=397&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OWL 2 has just been <a href="http://www.w3.org/blog/SW/2009/09/23/owl_2_is_a_proposed_recommendation">published as a Proposed Recommendation</a> (yay!) which means, in laymen’s term, that the technical work is done, and it is up to the membership of W3C to accept it as a full blown Recommendation.</p>
<p>As I already <a href="http://ivan-herman.name/2009/04/27/simple-owl-2-rl-service/">blogged before</a>, I did some <a href="http://www.ivan-herman.net/Misc/2008/owlrl/">implementation</a> work on a specific piece of OWL 2, namely the <a href="http://www.w3.org/TR/owl2-profiles/#OWL_2_RL">OWL 2 RL Profile</a>. (I have also <a href="http://ivan-herman.name/2008/12/03/bridge-between-sw-communities-owl-rl/">blogged about OWL 2 RL and its importance</a> before, nothing to repeat here.) The implementation itself is not really optimized, and it would probably not stand a chance for any large scale deployment (the reader may want to look at the <a href="http://www.w3.org/2007/OWL/wiki/Implementations">OWL 2 implementation report </a>for other alternatives).  But I can hope that the resulting <a href="http://www.ivan-herman.net/Misc/2008/owlrl/">service</a> can be useful in getting a feel for what OWL 2 RL can give you: by just adding a few triples into the text box you can see what OWL 2 RL means. This is, by the way, an implementation of the OWL 2 RL <em>rule set</em>, which means that it can also accepts triples that are not mandated by the Direct Semantics of OWL 2 (a.k.a. OWL 2 DL). Put it another way, it is an implementation of a small portion of OWL 2 Full.</p>
<p>The core of my implementation turned out to be really easy straightforward: a forward chaining structure directly encoded in Python. I use <a href="http://rdflib.net">RDFLib</a> to handle the RDF triples and the triple store. Each triple in the RDF Graph is considered, compared to the premises of the rules; if there is a match then new triples are added to the Graph. (Well, most of the rules contain several triples to match with, and the usual approach is to pick one and explore the Graph deeper check against additional matches. Which one to pick is important, it may affect the overall speed, though.) If, through such a cycle, no additional triples are added to the Graph then we are done, the “deductive closure” of the Graph has been calculated. The rules of OWL 2 RL have been carefully chosen so that no new resources are added to the Graph (only new triples), ie, this process eventually stops.</p>
<p>The <a href="http://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules">rules themselves</a> are usually simple. Although it is possible and probably more efficient to encode the whole process using some sort of a rule engine (I know of implementations based on, eg, Jena’s rules or Jess), one can simply encode the rules using the usual conditional constructs of the programming language. The number of rules is relatively high but nothing that a good screen editor would not manage with copy-paste. There were only a few rules that required a somewhat more careful coding (usually to take care of lists) or many searches through the graph like, for examples, the rule for property chains (see rule prp-spo2 in the <a href="http://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules">rule set</a>). It is also important to note that the higher number of rules does really not affect the efficiency of the final system; if no triple matches a rule then, well, it just does not fire. No side effect of the mere existence of an unused rule.</p>
<p>So is it all easy and rosy? Not quite. First of all, this implementation is of course simplistic in so far as it generates <em>all</em> possible deducted triples that include a number of trivial triples (like <code>?x owl:sameAs ?x</code> for all possible resources). That means that the resulting graph becomes fairly big even if the (optional) axiomatic triples are not added. If the OWL 2 RL process is bound to a query engine (eg, the new version of SPARQL will, hopefully, give a precise specification of what it means to have OWL 2 RL reasoning on the data set prior to a SPARQL query) then many of these trivial triples could be generated at query time only, thereby avoiding an extra load on the database. Well, that is one place where a proof-of-concept and simple implementation like mine looses against a more professional one:-)</p>
<p>The second issue was the contrast between RDF triples and “generalized” RDF triples, ie, triples where literals can appear in subject positions and bnodes can appear as properties. OWL 2 explicitly says that it works with generalized triples and the OWL 2 RL rule set also shows why that is necessary. Indeed, consider the following set of triples:</p>
<pre>ex:X rdfs:subClassOf [
  a owl:Restriction;
  owl:onProperty [ owl:inverseOf ex:p ];
  owl:allValuesFrom ex:A
].</pre>
<p>This is a fairly standard “idiom” even for simple ontologies; one wants to restrict, so to say, the subjects instead of the objects using an OWL property restriction. In other words that restriction combined with</p>
<pre>ex:x rdf:type ex:X .
ex:y ex:p ex:x .</pre>
<p>should yield</p>
<pre>ex:y rdf:type ex:A .</pre>
<p>Well, this deduction would <em>not</em> occur through the rule set if non-generalized RDF triples were used. Indeed, the inverse of <code>ex:p</code> is a blank node, ie, using it in a triple is not legal; but using that blank node to denote a property is necessary for the full chain of deductions. In other words, to get that deduction to work properly using RDF and rules, the author of the vocabulary would have to give an explicit URI to the inverse of <code>ex:p</code>. Possible, but slightly unnatural. If generalized triples are used, then the OWL 2 RL rules yield the proper result.</p>
<p>It turns out that, in my case, having bnodes as properties was not really an issue, because RDFLib could handle that directly (is that a bug in RDFLib?). But similar, though slightly more complex or even pathological examples can be constructed involving literals in subject positions, and that <em>was</em> a problem because RDFLib refused to handle those triples. What I had to do was to exchange all literals in the graph against a new bnode, perform all the deductions using those, and exchange the bnodes “back” against their original literals at the end. (This mechanism is not my invention; it is actually described by the RDF Semantics document, in the section on <a href="http://www.w3.org/TR/rdf-mt/#DtypeRules">Datatype entailment rules</a>.) B.t.w., the triples returned by the system are all “legal” triples, generalized triples play a role during the deduction only (and illegal triples are filtered out at output).</p>
<p>Literals with datatypes were also a source of problems. This is probably where I spent most of my implementation time (I must thank <a href="http://km.aifb.uni-karlsruhe.de/projects/owltests/index.php/User:Michael_Schneider">Michael Schneider</a> who, while developing the <a href="http://km.aifb.uni-karlsruhe.de/projects/owltests/index.php/User:Michael_Schneider">test cases for OWL 2 RDF Based Semantics</a>, was constantly pushing me to handle those damn datatypes properly…). Indeed, the underlying RDFLib system is fairly lax on checking the typed literals against their definition by the <a href="http://www.w3.org/TR/xmlschema11-2/">XSD specification</a> (eg, issues like minimum or maximum values were not checked…). As a consequence, I had to re-implement the lexical to value conversion for all datatypes. Once I found out how to do that (I had dive a bit into the internals of RDFLib but, luckily, Python is an interpretative language…) it became a relatively straightforward, repetitive, and slightly time consuming work. Actually, using bnodes instead of “real” literals made it easier to implement datatype subsumptions, too (eg, the fact that, say, an <code>xsd:byte</code> is also a <code>xsd:integer</code>). This became important so that the rules would work properly on property restrictions involving datatypes.</p>
<p>Bottom line: even for a simple implementation literals, mainly literals with datatypes, are the biggest headache. The rest is <em>really</em> easy.  (This is hardly the discovery of the year, but is nevertheless good to remember…)</p>
<p>I was, actually, carried away a bit once I got a hold on how to handle datatypes, so I also implemented a small “extension” to OWL 2 RL by adding <a href="http://www.w3.org/TR/2009/PR-owl2-syntax-20090922/#Datatype_Maps">datatype restrictions</a> (one of the really nice new features of OWL 2 but which is not mandated for OWL 2 RL). Imagine you have the following vocabulary item:</p>
<pre>ex:RE a owl:Restriction ;
    owl:onProperty ex:p ;
    owl:someValuesFrom [
      a rdfs:Datatype ;
      owl:onDatatype xsd:integer ;
      owl:withRestrictions (
          [ xsd:minInclusive "1"^^xsd:integer ]
          [ xsd:maxInclusive "6"^^xsd:integer ]
      )
   ] .</pre>
<p>which defines a restriction on the property <code>ex:p</code> so that some its values should be integers in the <code>[1,6]</code> interval. This means that</p>
<pre>ex:q ex:p "2"^^xsd:integer.</pre>
<p>yields</p>
<pre>ex:q rdf:type ex:RE .</pre>
<p>And this could be done by a slight extension of OWL 2 RL; no new rules, just adding the datatype restrictions to the datatypes. Nifty…</p>
<p>That is it. I had fun, and maybe it will be useful to others. The package can also be <a href="http://dev.w3.org/2004/PythonLib-IH/dist/RDFClosure.tar.gz">downloaded</a> and used with RDFLib, by the way…</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=3e3ccb41-b213-4ff3-9438-7c6191ac6f1f" alt="" /></div>
<br />Posted in Python, Semantic Web, Work Related Tagged: Description logic, Knowledge Representation, OWL, OWL RL, Python, RDF, RDFLib, Resource Description Framework, SPARQL, w3c <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/397/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=397&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2009/09/29/owl-2-rl-closure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/pixy.gif?x-id=3e3ccb41-b213-4ff3-9438-7c6191ac6f1f" medium="image" />
	</item>
		<item>
		<title>Simple OWL 2 RL service</title>
		<link>http://ivan-herman.name/2009/04/27/simple-owl-2-rl-service/</link>
		<comments>http://ivan-herman.name/2009/04/27/simple-owl-2-rl-service/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 13:12:32 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[OWL]]></category>
		<category><![CDATA[OWL RL]]></category>
		<category><![CDATA[Resource Description Framework]]></category>
		<category><![CDATA[SPARQL]]></category>

		<guid isPermaLink="false">http://ivan-herman.name/?p=294</guid>
		<description><![CDATA[The W3C OWL Working group has published a number of OWL 2 documents last week. This included an updated version of the OWL 2 RL profile. I have already blogged about this profile (“Bridge Between SW communities: OWL RL”) when the previous release was published; there are no radical changes in this release, so there [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=294&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The W3C OWL Working group has <a href="http://www.w3.org/blog/SW/2009/04/22/new_owl_2_working_drafts">published a number of OWL 2 documents</a> last week. This included an updated version of the <a href="http://www.w3.org/TR/2009/WD-owl2-profiles-20090421/#OWL_2_RL">OWL 2 RL profile</a>.  I have already blogged about this profile (<a href="http://ivan-herman.name/2008/12/03/bridge-between-sw-communities-owl-rl/">“Bridge Between SW communities: OWL RL”</a>) when the previous release was published; there are no radical changes in this release, so there is no reason to repeat what was said there.</p>
<p>I have been playing with a simple and naive implementation of OWL 2 RL for a while; I have now decided to live dangerously;-) and release the software and the corresponding service. So… you can go to the <a href="http://www.ivan-herman.net/Misc/2008/owlrl/">OWL 2 RL generator service</a>, give an RDF graph, and see what RDF triples an OWL 2 RL system should generate. It should give you some ideas of what OWL 2 RL is all about.</p>
<p>I cannot emphasize enough that this is <em>not </em> a production level tool. Beyond the bugs that I have not yet found, a proper implementation would, for example, optimize the <code>owl:sameAs</code> triples and, instead of storing them in the graph, would generate those on the fly when, say, a SPARQL request is issued. But my goal was not to produce something optimal; instead, I wanted to see whether OWL 2 RL can be implemented without any sophisticated tool or not. The answer is: yes it can. This also means that if I could do it, anybody with a basic knowledge of the underlying RDF environment and programming language (RDFLib and Python in this case) can do it, too. No need to be familiar with any complex algorithms, rule language implementation tricks, complicated external tools, description logic concepts, whatever…</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=f83b8938-30f4-41ee-b3c9-3369db879adf" alt="" /></div>
<br />Posted in Code, Python, Semantic Web, Work Related Tagged: OWL, OWL RL, Python, Resource Description Framework, SPARQL <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/294/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=294&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2009/04/27/simple-owl-2-rl-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/pixy.gif?x-id=f83b8938-30f4-41ee-b3c9-3369db879adf" medium="image" />
	</item>
		<item>
		<title>New Python releases</title>
		<link>http://ivan-herman.name/2008/12/06/new-python-releases/</link>
		<comments>http://ivan-herman.name/2008/12/06/new-python-releases/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 09:17:02 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[Backward compatibility]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Programming language]]></category>

		<guid isPermaLink="false">http://ivanherman.wordpress.com/?p=204</guid>
		<description><![CDATA[The fact that there are new Python releases is nothing new. But this time it is a bit different. While there is a new, 2.6.1 version of Python (which is “just” and upgrade), there is now also a 3.0 version (a.k.a. Python 3000). And Python 3.0 is not backward compatible with the older Python versions. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=204&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The fact that there are new Python releases is nothing new. But this time it is a bit different. While there is a new, <a href="http://www.python.org/download/releases/2.6.1/">2.6.1 version of Python</a> (which is “just” and upgrade), there is now also a <a href="http://www.python.org/download/releases/3.0/">3.0 version</a> (a.k.a. Python 3000). And Python 3.0 <em>is not backward compatible with the older Python versions</em>. Although the differences are not radical (see the “<a href="http://docs.python.org/3.0/whatsnew/3.0.html">what is new?</a>” page), it is still true that older Python applications may not run with Python 3.0.</p>
<p>I must admit that I am a bit skeptical about this move. I just do not want to spend my time changing my old Python applications to run Python 3.0 even if they need further development and I am probably not the only one. Of course, for the time being, I can get by, because the Python community plans to maintain the 2.X lines in parallel with the 3.X line. But for how long?</p>
<p>The beauty of Python was (and still is) its simplicity and, compared to many other programming languages, its ease of use. It has already grown a little bit too complex for my taste in the past few years (E.g., I have never really grasped the big importance of, say, decorators and I never used those), but I could safely ignore those if I wanted. As far as I am concerned, none of the <a href="http://docs.python.org/3.0/whatsnew/3.0.html">new, incompatible features in Python 3000</a> warranted such a radical change (well, maybe the better handling of unicode makes a major difference). I am a little bit afraid that the Python community has shot itself in the foot with this move which may become a maintainers’ nightmare. I am happy to be proven otherwise, though…</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=5096214b-e81a-4b54-ad82-5b73b4468234" alt="" /></div>
<br />Posted in Python, Work Related Tagged: Backward compatibility, Computer programming, Programming language, Python <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/204/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=204&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2008/12/06/new-python-releases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/pixy.gif?x-id=5096214b-e81a-4b54-ad82-5b73b4468234" medium="image" />
	</item>
		<item>
		<title>Setting up and RDFa file with Apache (second)</title>
		<link>http://ivan-herman.name/2008/04/27/setting-up-and-rdfa-file-with-apache-second/</link>
		<comments>http://ivan-herman.name/2008/04/27/setting-up-and-rdfa-file-with-apache-second/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 22:58:28 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[RDFa]]></category>

		<guid isPermaLink="false">http://ivanherman.wordpress.com/?p=109</guid>
		<description><![CDATA[A few weeks ago I wrote a short post on how I set up an RDFa file with apache. As commented there by masaka (and I also received some private comments), that setup had the disadvantage that if a client had an accept header that referred both to HTML and to RDF, then it went [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=109&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote a <a href="http://ivanherman.wordpress.com/2008/02/22/setting-up-an-rdfa-with-apache/">short post</a> on how I set up an RDFa file with apache. As commented there by masaka (and I also received some private comments), that setup had the disadvantage that if a client had an accept header that referred <em>both </em>to HTML and to RDF, then it went wrong. Essentially, the server picked whichever was first in the <code>.htaccess</code> file.</p>
<p>So I had to revise (and ask advise from those who understand how Apache works). Here is how SW-FAQ is now set up. It is a little bit more complicated and requires the “.var” facilities to be switched on in Apache. In the same directory where I store the <code>SW-FAQ.html</code> file, I also store a <code>SW-FAQ.var</code> file (called a “type map file”). It looks as follows:</p>
<pre>URI: SW-FAQ

URI: SW-FAQ.html
Content-Type: text/html

URI: SW-FAQ.rdf
Content-Type: application/rdf+xml; qs=0.5
</pre>
<p>the .htaccess file in the same directory is now simpler; it just says:</p>
<pre>RewriteEngine On
RewriteBase /2001/sw/
RewriteRule SW-FAQ.rdf /2007/08/pyRdfa/extract?uri=http://www.w3.org/2001/sw/SW-FAQ.html [L]
</pre>
<p>The .var file switches in <a href="http://httpd.apache.org/docs/2.0/content-negotiation.html">Apache’s content negotiation</a> mechanism. The media type determines which version is returned, and this takes into account the “quality” parameter of the HTTP accept header, too. The <code>.htaccess</code> file would then just direct the server to run the RDFa distiller and return the result when RDF is required. This seems to work better…</p>
<p>(It was TimBL who pushed me to do the changes this time, and the basic structure comes from him, actually…)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ivanherman.wordpress.com/109/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ivanherman.wordpress.com/109/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=109&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2008/04/27/setting-up-and-rdfa-file-with-apache-second/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>
	</item>
		<item>
		<title>RDFa Syntax LC is out</title>
		<link>http://ivan-herman.name/2008/02/21/rdfa-syntax-lc-is-out/</link>
		<comments>http://ivan-herman.name/2008/02/21/rdfa-syntax-lc-is-out/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 18:41:23 +0000</pubDate>
		<dc:creator>Ivan Herman</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Work Related]]></category>

		<guid isPermaLink="false">http://ivanherman.wordpress.com/?p=98</guid>
		<description><![CDATA[The RDFa Syntax Last Call document has just been published; yey! I have also made an update of the RDFa processor that I coded last summer; it is now available for download and is also used through the “RDFa Distiller” service page. I have played with RDFa in practical terms, too; my foaf file in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=98&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.w3.org/blog/SW/2008/02/21/rdfa_syntax_last_call_working_draft">RDFa Syntax Last Call document has just been published</a>; yey!</p>
<p>I have also made an update of the <a href="http://ivanherman.wordpress.com/2007/09/03/yet-another-rdfa-processor%e2%80%a6/">RDFa processor </a>that I coded last summer; it is now <a href="http://dev.w3.org/2004/PythonLib-IH/dist/pyRdfa.tar.gz">available for download</a> and is also used through the “<a href="http://www.w3.org/2007/08/pyRdfa/">RDFa Distiller</a>” service page. I have played with RDFa in practical terms, too; <a href="http://www.ivan-herman.net/foaf.html">my foaf file in HTML</a>, the <a href="http://www.w3.org/2001/sw/">W3C SW Activity Home page</a>, and the <a href="http://www.w3.org/2001/sw/SW-FAQ.html">Semantic Web FAQ page</a> are all annotated with RDFa now. Once one is used to it, it is fairly straightforward to add even complex RDF statements to HTML pages with an arbitrarily large number of different vocabularies mixed in. Of course, authoring tools would be good, but let us take things one step at a time… Having the Last Call published (ie, the Working Groups believing to have taken care of all technical issues) is a major, big step ahead!</p>
<p>B.t.w., <a href="http://bnode.org">Benjamin Nowack</a> jumped on the <a href="http://www.w3.org/2001/sw/SW-FAQ.rdf">SW-FAQ RDF file</a> to make a nice little hack; here is the mail he sent on the SW SWEO list the other day:</p>
<blockquote><p> Heh, silly stuff, just FYI: On the #foaf channel is foafbot (a SPARQLy reincarnation<br />
of an earlierbot we had there years ago). It understands RDFa, and allows the<br />
specification of custom commands at [1]. I made it load Ivan&#8217;s FAQ, and<br />
created an &#8220;faq&#8221; command, so that you can now pass a keyword or phrase<br />
to the bot and it will respond with a pointer to the FAQ (if something<br />
matched the RDFa-encoded question), e.g.:</p>
<p>&lt;bengee&gt; foafbot, faq giant ontology</p>
<p>&lt;foafbot&gt; bengee, see http://www.w3.org/2001/sw/SW-FAQ#whgiantont</p>
<p> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Benji</p>
<p>[1] http://semsol.org/semcamp/sparqlbot</p></blockquote>
<p>Isn&#8217;t that cool? As far as I could see, it took him about 10 minutes to add this hack, thanks to the SW-FAQ being in RDF…</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ivanherman.wordpress.com/98/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ivanherman.wordpress.com/98/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivanherman.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivanherman.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivanherman.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivanherman.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivanherman.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivanherman.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivanherman.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivanherman.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivanherman.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivanherman.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivanherman.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivanherman.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivanherman.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivanherman.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivan-herman.name&amp;blog=557157&amp;post=98&amp;subd=ivanherman&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivan-herman.name/2008/02/21/rdfa-syntax-lc-is-out/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ee636fa218fc08a28db5288c2149e309?s=96&#38;d=identicon" medium="image">
			<media:title type="html">ivanherman</media:title>
		</media:content>
	</item>
	</channel>
</rss>
