Getting RDF N3 From HyperText

If you Webize "rel" and mark up your HyperText links like so:-

   <a href="http://robustai.net/#Seth" rel="#collaborator">Seth</a>

With "rel" as the predicate, and "href" as the object. Then it becomes
very easy to XSLT transform it into N3:-

   <> <#collaborator> <http://robustai.net/#Seth> .

Plus, you can use the "title" element to display the predicate as
well, so you can "browse" the RDF. I wrote the following XSLT script
to extract the rel attribute as a predicate, and the href attribute as
the object:-

<stylesheet
    xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:h="http://www.w3.org/1999/xhtml" >
<output method="text"/>
<template match="h:html">
<text>@prefix : &lt;#&gt; .
</text>
 <apply-templates/>
</template>
<template match="/h:html/h:body">
 <for-each select=".//h:a">
   <text>&lt;&gt; </text><value-of select="(@rel)" /><text>
&lt;</text><value-of select="(@href)" /><text>&gt; .
</text>
 </for-each>
</template>
<template match="text()|@*">
</template>
</stylesheet>

It's up at http://infomesh.net/2001/03/xhtmlton3/xhtmlton3.xsl You can
use http://infomesh.net/2001/03/xhtmlton3/test.html as a test
document. Dan Connolly has a form up at
http://www.w3.org/2000/06/dc-extract/form.html that I often use for
this sort of thing... the output for the above is at:-

http://www.w3.org/2000/06/webdata/xslt?xslfile=http%3A%2F%2Finfomesh.n
et%2F2001%2F03%2Fxhtmlton3%2Fxhtmlton3.xsl&xmlfile=http%3A%2F%2Finfome
sh.net%2F2001%2F03%2Fxhtmlton3%2Ftest.html

Which gives:-

     @prefix : <#> .
     <> <#collaborator> <http://robustai.net/Person/#Seth> .
     <> <#collaborator> <http://purl.org/swag/Person/#Sean> .

Hey, now you can use your Web browser as a makeshift semBrowser :-)

--
Kindest Regards,
Sean B. Palmer
@prefix : <http://webns.net/roughterms/> .
:Sean :hasHomepage <http://infomesh.net/sbp/> .

Received on Friday, 2 March 2001 12:39:40 UTC