turtle serializer for jena model webacl
authorAlexandre Bertails <bertails@w3.org>
Mon, 21 Nov 2011 13:31:35 -0500
branchwebacl
changeset 135 071c0931f322
parent 134 4f7578d03d3c
child 136 0012041ebba9
turtle serializer for jena model
src/main/scala/rdf/JenaModel.scala
src/main/scala/rdf/RDFModel.scala
src/main/scala/rdf/main.scala
src/main/scala/rdf/turtle.scala
src/test/resources/card.n3
src/test/resources/card.rdf
--- a/src/main/scala/rdf/JenaModel.scala	Mon Nov 21 12:00:02 2011 -0500
+++ b/src/main/scala/rdf/JenaModel.scala	Mon Nov 21 13:31:35 2011 -0500
@@ -1,135 +1,135 @@
-//package org.w3.rdf.jena
-//
-//import org.w3.rdf._
-//import com.hp.hpl.jena.graph.{Graph => JenaGraph, Triple => JenaTriple, Node => JenaNode, _}
-//import com.hp.hpl.jena.rdf.model.{AnonId}
-//import com.hp.hpl.jena.datatypes.{RDFDatatype, TypeMapper}
-//import org.w3.readwriteweb.util.trySome
-//
-//import org.w3.isomorphic._
-//
-//trait JenaModel extends RDFModel {
-//
-//  case class IRI(iri: String) { override def toString = '"' + iri + '"' }
-//  object IRI extends Isomorphic1[String, IRI]
-//
-//  class Graph(val jenaGraph: JenaGraph) extends GraphLike {
-//    def iterator: Iterator[Triple] = new Iterator[Triple] {
-//      val iterator = jenaGraph.find(JenaNode.ANY, JenaNode.ANY, JenaNode.ANY)
-//      def hasNext = iterator.hasNext
-//      def next = iterator.next
-//    }
-//    
-//    def ++(other: Graph): Graph = {
-//      val g = Factory.createDefaultGraph
-//      iterator foreach { t => g add t }
-//      other.iterator foreach { t => g add t }
-//      new Graph(g)
-//    }
-//
-//    override def equals(o: Any): Boolean =
-//      ( o.isInstanceOf[Graph] && jenaGraph.isIsomorphicWith(o.asInstanceOf[Graph].jenaGraph) )
-//
-//  }
-//
-//  object Graph {
-//    def empty: Graph = new Graph(Factory.createDefaultGraph)
-//    def apply(elems: Triple*): Graph = apply(elems.toIterable)
-//    def apply(it: Iterable[Triple]): Graph = {
-//      val jenaGraph = Factory.createDefaultGraph
-//      it foreach { t => jenaGraph add t }
-//      new Graph(jenaGraph)
-//    }
-//  }
-//
-//  type Triple = JenaTriple
-//  object Triple extends Isomorphic3[Subject, Predicate, Object, Triple] {
-//    def apply(s: Subject, p: Predicate, o: Object): Triple = JenaTriple.create(s, p, o)
-//    def unapply(t: Triple): Option[(Subject, Predicate, Object)] =
-//      Some((t.getSubject, t.getPredicate, t.getObject))
-//  }
-//
-//  type BNode = Node_Blank
-//  object BNode extends Isomorphic1[String, BNode] {
-//    def apply(label: String): BNode = {
-//      val id = AnonId.create(label)
-//      JenaNode.createAnon(id).asInstanceOf[Node_Blank]
-//    }
-//    def unapply(bn: BNode): Option[String] = trySome(bn.getBlankNodeId.getLabelString)
-//  }
-//
-//  type Node = JenaNode
-//  type NodeIRI = Node_URI
-//  object NodeIRI extends Isomorphic1[IRI, NodeIRI] {
-//    def apply(iri: IRI): NodeIRI = {
-//      val IRI(s) = iri
-//      JenaNode.createURI(s).asInstanceOf[Node_URI]
-//    }
-//    def unapply(node: NodeIRI): Option[IRI] = trySome(IRI(node.getURI))
-//  }
-//  type NodeBNode = Node_Blank
-//  object NodeBNode extends Isomorphic1[BNode, NodeBNode] {
-//    def apply(node: BNode): NodeBNode = node
-//    def unapply(node: NodeBNode): Option[BNode] =
-//      if (node.isBlank) Some(node) else None
-//  }
-//
-//  type Subject = JenaNode
-//  type SubjectNode = JenaNode
-//  object SubjectNode extends Isomorphic1[Node, SubjectNode] {
-//    def apply(node: Node): SubjectNode = node
-//    def unapply(node: SubjectNode): Option[Node] = Some(node)
-//  }
-//
-//  type Predicate = JenaNode
-//  type PredicateIRI = JenaNode
-//  object PredicateIRI extends Isomorphic1[IRI, PredicateIRI] {
-//    def apply(iri: IRI): PredicateIRI = { val IRI(s) = iri ; JenaNode.createURI(s) }
-//    def unapply(node: PredicateIRI): Option[IRI] = trySome(IRI(node.getURI))
-//  }
-//
-//  type Object = JenaNode
-//  type ObjectNode = JenaNode
-//  object ObjectNode extends Isomorphic1[Node, ObjectNode] {
-//    def apply(node: Node): ObjectNode = node
-//    def unapply(node: ObjectNode): Option[Node] =
-//      if (node.isURI || node.isBlank) Some(node) else None
-//  }
-//  type ObjectLiteral = JenaNode
-//  object ObjectLiteral extends Isomorphic1[Literal, ObjectLiteral] {
-//    def apply(literal: Literal): ObjectLiteral = literal
-//    def unapply(node: ObjectLiteral): Option[Literal] =
-//      if (node.isLiteral) Some(node.asInstanceOf[Node_Literal]) else None
-//  }
-//
-//  type Literal = Node_Literal
-//  type PlainLiteral = Node_Literal
-//  object PlainLiteral extends Isomorphic2[String, Option[LangTag], PlainLiteral] {
-//    def apply(lit: String, langtagOption: Option[LangTag]) =
-//      langtagOption match {
-//        case Some(LangTag(langtag)) => JenaNode.createLiteral(lit, langtag, false).asInstanceOf[Node_Literal]
-//        case None => JenaNode.createLiteral(lit).asInstanceOf[Node_Literal]
-//      }
-//    def unapply(literal: PlainLiteral): Option[(String, Option[LangTag])] =
-//      trySome { ( literal.getLiteralValue.toString, Option(LangTag(literal.getLiteralLanguage)) ) }
-//  }
-//  
-//  type TypedLiteral = Node_Literal
-//  lazy val mapper = TypeMapper.getInstance
-//  object TypedLiteral extends Isomorphic2[String, IRI, TypedLiteral] {
-//    def apply(lit: String, iri: IRI): TypedLiteral = {
-//      val IRI(typ) = iri
-//      JenaNode.createLiteral(lit, null, mapper.getTypeByName(typ)).asInstanceOf[Node_Literal]
-//    }
-//    def unapply(literal: TypedLiteral): Option[(String, IRI)] =
-//      trySome((literal.getLiteralValue.toString, IRI(literal.getLiteralDatatype.getURI)))
-//  }
-//
-//  case class LangTag(s: String)
-//  object LangTag extends Isomorphic1[String, LangTag]
-//
-//}
-//
-//object JenaModel extends JenaModel
-//
-//object JenaModelWithImplicits extends JenaModel with Implicits
\ No newline at end of file
+package org.w3.rdf.jena
+
+import org.w3.rdf._
+import com.hp.hpl.jena.graph.{Graph => JenaGraph, Triple => JenaTriple, Node => JenaNode, _}
+import com.hp.hpl.jena.rdf.model.{AnonId}
+import com.hp.hpl.jena.datatypes.{RDFDatatype, TypeMapper}
+import org.w3.readwriteweb.util.trySome
+
+import org.w3.isomorphic._
+
+trait JenaModel extends RDFModel {
+
+  case class IRI(iri: String) { override def toString = '"' + iri + '"' }
+  object IRI extends Isomorphic1[String, IRI]
+
+  class Graph(val jenaGraph: JenaGraph) extends GraphLike {
+    def iterator: Iterator[Triple] = new Iterator[Triple] {
+      val iterator = jenaGraph.find(JenaNode.ANY, JenaNode.ANY, JenaNode.ANY)
+      def hasNext = iterator.hasNext
+      def next = iterator.next
+    }
+    
+    def ++(other: Graph): Graph = {
+      val g = Factory.createDefaultGraph
+      iterator foreach { t => g add t }
+      other.iterator foreach { t => g add t }
+      new Graph(g)
+    }
+
+    override def equals(o: Any): Boolean =
+      ( o.isInstanceOf[Graph] && jenaGraph.isIsomorphicWith(o.asInstanceOf[Graph].jenaGraph) )
+
+  }
+
+  object Graph {
+    def empty: Graph = new Graph(Factory.createDefaultGraph)
+    def apply(elems: Triple*): Graph = apply(elems.toIterable)
+    def apply(it: Iterable[Triple]): Graph = {
+      val jenaGraph = Factory.createDefaultGraph
+      it foreach { t => jenaGraph add t }
+      new Graph(jenaGraph)
+    }
+  }
+
+  type Triple = JenaTriple
+  object Triple extends Isomorphic3[Subject, Predicate, Object, Triple] {
+    def apply(s: Subject, p: Predicate, o: Object): Triple = JenaTriple.create(s, p, o)
+    def unapply(t: Triple): Option[(Subject, Predicate, Object)] =
+      Some((t.getSubject, t.getPredicate, t.getObject))
+  }
+
+  type BNode = Node_Blank
+  object BNode extends Isomorphic1[String, BNode] {
+    def apply(label: String): BNode = {
+      val id = AnonId.create(label)
+      JenaNode.createAnon(id).asInstanceOf[Node_Blank]
+    }
+    def unapply(bn: BNode): Option[String] = trySome(bn.getBlankNodeId.getLabelString)
+  }
+
+  type Node = JenaNode
+  type NodeIRI = Node_URI
+  object NodeIRI extends Isomorphic1[IRI, NodeIRI] {
+    def apply(iri: IRI): NodeIRI = {
+      val IRI(s) = iri
+      JenaNode.createURI(s).asInstanceOf[Node_URI]
+    }
+    def unapply(node: NodeIRI): Option[IRI] = trySome(IRI(node.getURI))
+  }
+  type NodeBNode = Node_Blank
+  object NodeBNode extends Isomorphic1[BNode, NodeBNode] {
+    def apply(node: BNode): NodeBNode = node
+    def unapply(node: NodeBNode): Option[BNode] =
+      if (node.isBlank) Some(node) else None
+  }
+
+  type Subject = JenaNode
+  type SubjectNode = JenaNode
+  object SubjectNode extends Isomorphic1[Node, SubjectNode] {
+    def apply(node: Node): SubjectNode = node
+    def unapply(node: SubjectNode): Option[Node] = Some(node)
+  }
+
+  type Predicate = JenaNode
+  type PredicateIRI = JenaNode
+  object PredicateIRI extends Isomorphic1[IRI, PredicateIRI] {
+    def apply(iri: IRI): PredicateIRI = { val IRI(s) = iri ; JenaNode.createURI(s) }
+    def unapply(node: PredicateIRI): Option[IRI] = trySome(IRI(node.getURI))
+  }
+
+  type Object = JenaNode
+  type ObjectNode = JenaNode
+  object ObjectNode extends Isomorphic1[Node, ObjectNode] {
+    def apply(node: Node): ObjectNode = node
+    def unapply(node: ObjectNode): Option[Node] =
+      if (node.isURI || node.isBlank) Some(node) else None
+  }
+  type ObjectLiteral = JenaNode
+  object ObjectLiteral extends Isomorphic1[Literal, ObjectLiteral] {
+    def apply(literal: Literal): ObjectLiteral = literal
+    def unapply(node: ObjectLiteral): Option[Literal] =
+      if (node.isLiteral) Some(node.asInstanceOf[Node_Literal]) else None
+  }
+
+  type Literal = Node_Literal
+  type PlainLiteral = Node_Literal
+  object PlainLiteral extends Isomorphic2[String, Option[LangTag], PlainLiteral] {
+    def apply(lit: String, langtagOption: Option[LangTag]) =
+      langtagOption match {
+        case Some(LangTag(langtag)) => JenaNode.createLiteral(lit, langtag, false).asInstanceOf[Node_Literal]
+        case None => JenaNode.createLiteral(lit).asInstanceOf[Node_Literal]
+      }
+    def unapply(literal: PlainLiteral): Option[(String, Option[LangTag])] =
+      trySome { ( literal.getLiteralValue.toString, Option(LangTag(literal.getLiteralLanguage)) ) }
+  }
+  
+  type TypedLiteral = Node_Literal
+  lazy val mapper = TypeMapper.getInstance
+  object TypedLiteral extends Isomorphic2[String, IRI, TypedLiteral] {
+    def apply(lit: String, iri: IRI): TypedLiteral = {
+      val IRI(typ) = iri
+      JenaNode.createLiteral(lit, null, mapper.getTypeByName(typ)).asInstanceOf[Node_Literal]
+    }
+    def unapply(literal: TypedLiteral): Option[(String, IRI)] =
+      trySome((literal.getLiteralValue.toString, IRI(literal.getLiteralDatatype.getURI)))
+  }
+
+  case class LangTag(s: String)
+  object LangTag extends Isomorphic1[String, LangTag]
+
+}
+
+object JenaModel extends JenaModel
+
+object JenaModelWithImplicits extends JenaModel with Implicits
\ No newline at end of file
--- a/src/main/scala/rdf/RDFModel.scala	Mon Nov 21 12:00:02 2011 -0500
+++ b/src/main/scala/rdf/RDFModel.scala	Mon Nov 21 13:31:35 2011 -0500
@@ -50,7 +50,6 @@
   val ObjectNode: Isomorphic1[Node, ObjectNode]
   val ObjectLiteral: Isomorphic1[Literal, ObjectLiteral]
 
-  val Literal: PatternMatching1[Literal, Literal]
   val PlainLiteral: Isomorphic2[String, Option[LangTag], PlainLiteral]
   val TypedLiteral: Isomorphic2[String, IRI, TypedLiteral]
 
--- a/src/main/scala/rdf/main.scala	Mon Nov 21 12:00:02 2011 -0500
+++ b/src/main/scala/rdf/main.scala	Mon Nov 21 13:31:35 2011 -0500
@@ -76,22 +76,24 @@
 //    val g = turtle.toGraph(new File("/tmp/card.n3"))
 
     //import org.w3.rdf.jena.JenaModel
-    val rdf = ConcreteRDFModel
+    //val rdf = ConcreteRDFModel
+    val rdf = org.w3.rdf.jena.JenaModel
     
     val rdfxmlParser = org.w3.rdf.rdfxml.RDFXMLParser(rdf)
     
-    val g: rdf.Graph = rdfxmlParser.parse(new File("/tmp/card.rdf"))
+    val g: rdf.Graph = rdfxmlParser.parse(new File("src/test/resources/card.rdf"))
 
 //    val m:Graph = g.jenaGraph
     
-    val s = new org.w3.rdf.turtle.TurtleSerializer
-    
-    //println(s.showAsString(rdf)(g))
+    //val s = org.w3.rdf.turtle.ConcreteTurtleSerializer
+    val s = org.w3.rdf.turtle.JenaTurtleSerializer
     
-    import rdf._
-    val ol = ObjectLiteral(PlainLiteral("The Next Wave of the Web (Plenary Panel)",None))
+    println(s.asString(g, new java.net.URL("http://www.w3.org/People/Berners-Lee/card")))
     
-    println(s.objectStr(rdf)(ol))
+//    import rdf._
+//    val ol = ObjectLiteral(PlainLiteral("The Next Wave of the Web (Plenary Panel)",None))
+//    
+//    println(s.objectStr(ol))
     
     
     
--- a/src/main/scala/rdf/turtle.scala	Mon Nov 21 12:00:02 2011 -0500
+++ b/src/main/scala/rdf/turtle.scala	Mon Nov 21 13:31:35 2011 -0500
@@ -17,8 +17,6 @@
 
 class TurtleParser extends JavaTokenParsers {
   
-  import rdf._
-  
   def toGraph(t:String)(implicit rdf: RDFModel): rdf.Graph = parseAll(turtle, t).get
 
   def toGraph(file:java.io.File)(implicit rdf: RDFModel): rdf.Graph = {
@@ -96,26 +94,43 @@
   
 }
 
-// as the Module type does not escape from any method here, we can pass it at the constructor level
-class TurtleSerializer {
-  
-  //type RDFModel = ConcreteRDFModel
+import java.net.URL
+trait TurtleSerializer[RDF <: RDFModel] {
   
-  class Def[C](implicit desired : Manifest[C]) {
-     def unapply[X](c : X)(implicit m : Manifest[X]) : Option[C] = {
-       def sameArgs = desired.typeArguments.zip(m.typeArguments).forall {case (desired,actual) => desired >:> actual}
-       if (desired >:> m && sameArgs) Some(c.asInstanceOf[C])
-       else None
-     }
-   }
+  val rdf: RDF
   
-  def showAsString(rdf: RDFModel)(g: rdf.Graph): String = {
+  def asString(g: rdf.Graph, base: URL): String
+  
+}
+
+import org.w3.rdf.jena.JenaModel
+import com.hp.hpl.jena.rdf.model.{Model, ModelFactory}
+import org.w3.readwriteweb.TURTLE
+
+object JenaTurtleSerializer extends TurtleSerializer[JenaModel] {
+  
+  val rdf = JenaModel
+  
+  def asString(g: rdf.Graph, base: URL): String = {
+    val model = ModelFactory.createModelForGraph(g.jenaGraph)
+    val writer = model.getWriter(TURTLE.jenaLang)
+    val sw = new java.io.StringWriter
+    writer.write(model, sw, base.toString)
+    sw.toString
+  }
+  
+}
+
+object ConcreteTurtleSerializer extends TurtleSerializer[ConcreteRDFModel] {
+  
+  val rdf = ConcreteRDFModel
+  
+  def asString(g: rdf.Graph, base: URL): String = {
     g map {
       t =>
-        //val rdf.Triple(rdf.SubjectNode(s), rdf.PredicateIRI(p), o: rdf.Object) = t
-        val rdf.Triple(rdf.SubjectNode(s), rdf.PredicateIRI(p), o: rdf.Object) = t
+        val rdf.Triple(rdf.SubjectNode(s), rdf.PredicateIRI(p), o) = t
         try {
-          "%s %s %s" format (nodeStr(rdf)(s), iriStr(rdf)(p), objectStr(rdf)(o))
+          "%s %s %s" format (nodeStr(s), iriStr(p), objectStr(o))
         } catch {
           case e => {
             println("=== "+t)
@@ -128,31 +143,31 @@
     } mkString "\n"
   }
 
-  def objectStr(rdf: RDFModel)(n: rdf.Object): String = {
+  def objectStr(n: rdf.Object): String = {
     n match {
-      case rdf.ObjectNode(on) => nodeStr(rdf)(on)
-      case rdf.ObjectLiteral(l) => literalStr(rdf)(l)
-//      case on: rdf.ObjectNode => { val rdf.ObjectNode(oo) = on; nodeStr(rdf)(oo) }
-//      case l: rdf.ObjectLiteral => { val rdf.ObjectLiteral(ll) = l; literalStr(rdf)(ll) }
-      
+//       case l:rdf.ObjectLiteral => {
+//         val x:rdf.ObjectLiteral = l
+//         "**ObjectLiteral(" + x + ")**"
+//       }
+      case rdf.ObjectNode(n) => nodeStr(n)
+      case rdf.ObjectLiteral(l) => literalStr(l)
       case x => { sys.error(x.toString) }
     }
   }
 
-  private def nodeStr(rdf: RDFModel)(n: rdf.Node): String = {
+  private def nodeStr(n: rdf.Node): String = {
     n match {
-      case rdf.NodeIRI(i) => iriStr(rdf)(i)
-      case rdf.NodeBNode(b) => bnodeStr(rdf)(b)
+      case rdf.NodeIRI(i) => iriStr(i)
+      case rdf.NodeBNode(b) => bnodeStr(b)
     }
   }
 
-  private def iriStr(rdf: RDFModel)(i: rdf.IRI): String =
+  private def iriStr(i: rdf.IRI): String =
     "<%s>" format { val rdf.IRI(s) = i; s }
 
-  private def bnodeStr(rdf: RDFModel)(b: rdf.BNode): String =
+  private def bnodeStr(b: rdf.BNode): String =
     "_:" + { val rdf.BNode(l) = b; l }
  
-  private def literalStr(rdf: RDFModel)(l: rdf.Literal): String = l.toString
+  private def literalStr(l: rdf.Literal): String = l.toString
 
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/card.n3	Mon Nov 21 13:31:35 2011 -0500
@@ -0,0 +1,220 @@
+# N3
+# Personal information in machine-readable form
+#
+# This (card.n3) is Tim Berners-Lee's FOAF file. It is a data file with the 
+#    sort of information which would be on a home page.
+# This is RDF data.
+# This is written in Notation3 - see http://www.w3.org/DesignIssues/Notation3
+# See alternatively the RDF/XML file card.rdf generated from this.
+# Use the uri <http://www.w3.org/People/Berners-Lee/card> to refer to this
+#    file independent of the format.
+# Use the uri <http://www.w3.org/People/Berners-Lee/card#i> to refer to Tim BL.
+#
+@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
+@prefix doap:  <http://usefulinc.com/ns/doap#>.
+@prefix :      <http://www.w3.org/2000/10/swap/pim/contact#>.
+@prefix s:     <http://www.w3.org/2000/01/rdf-schema#>.
+@prefix cc:    <http://creativecommons.org/ns#>.
+@prefix dc:    <http://purl.org/dc/elements/1.1/>.
+@prefix dct:   <http://purl.org/dc/terms/>.
+@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix owl:   <http://www.w3.org/2002/07/owl#>.
+@prefix geo:   <http://www.w3.org/2003/01/geo/wgs84_pos#>.
+@prefix w3c:   <http://www.w3.org/data#>.
+@prefix card:  <http://www.w3.org/People/Berners-Lee/card#>.
+@prefix cert:  <http://www.w3.org/ns/auth/cert#> .
+@prefix rsa:   <http://www.w3.org/ns/auth/rsa#> .
+
+# About this document:
+# The <> (the empty URI) means "this document".
+
+    <>   a foaf:PersonalProfileDocument;
+         cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
+	 dc:title "Tim Berners-Lee's FOAF file";
+         foaf:maker card:i;
+         foaf:primaryTopic card:i.
+
+# Below we introduce a FOAF file I have write access to, which the tabulator
+# will let me edit.
+
+
+# Turn off this section to turn off the live editing of the FOAF file extension.
+# This is where my list of people I know is:
+<http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
+        a foaf:PersonalProfileDocument;  # Suitable place to edit
+        is rdfs:seeAlso of card:i;       # Go fetch it
+        cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
+        dc:title "Tim Berners-Lee's editable FOAF file";
+        foaf:maker card:i;
+        foaf:primaryTopic card:i.
+
+############## Stuff about me
+
+card:i
+    s:label  	"Tim Berners-Lee";   # For generic user interfaces etc
+    a :Male;
+    foaf:based_near [geo:lat "42.361860"; geo:long "-71.091840"];
+
+    :office [
+	:phone <tel:+1-617-253-5702>;
+	geo:location [geo:lat "42.361860"; geo:long "-71.091840"];
+	:address [
+		:street "32 Vassar Street";
+		:street2 "MIT CSAIL Room 32-G524";
+		:city "Cambridge";
+		:postalCode "02139";
+		:country "USA"
+	]
+    ];
+    :publicHomePage <../Berners-Lee/>;
+    :homePage <../Berners-Lee/>;     # hack - follows by RDFS from line above
+			    # The W3C structure data uses this as an IFP
+    is foaf:member of w3c:W3C;
+    :assistant card:amy;
+
+# Using FOAF vocabulary:
+
+    a foaf:Person;
+    # The idea is that this is the one I would suggest you use and 
+    # I use for myself, which can lead to others.
+    :preferredURI "http://www.w3.org/People/Berners-Lee/card#i"; # experimental
+    foaf:mbox <mailto:timbl@w3.org>;
+    foaf:mbox_sha1sum "965c47c5a70db7407210cef6e4e6f5374a525c5c";
+    foaf:openid <http://www.w3.org/People/Berners-Lee/>;
+    foaf:img <http://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg>;
+
+    foaf:family_name "Berners-Lee";
+    foaf:givenname "Timothy";
+    foaf:title "Sir";
+
+    foaf:homepage <http://www.w3.org/People/Berners-Lee/>;
+        is foaf:member of <http://dig.csail.mit.edu/data#DIG>; 
+     foaf:mbox <mailto:timbl@w3.org>;
+    #	 foaf:mbox_sha1sum "1839a1cc2e719a85ea7d9007f587b2899cd94064";
+     foaf:name "Timothy Berners-Lee";
+     foaf:nick "TimBL", "timbl";
+     foaf:phone <tel:+1-(617)-253-5702>;
+    #         foaf:schoolHomepage <http://www.w3.org/People/Berners-Lee>;
+    
+    
+    foaf:account <http://twitter.com/timberners_lee>,
+        <http://en.wikipedia.org/wiki/User:Timbl>,
+        <http://identi.ca/timbl>;
+
+    #         foaf:workInfoHomepage <http://www.w3.org/People/Berners-Lee>;
+     foaf:workplaceHomepage <http://www.w3.org/>.
+
+
+## Facebook
+
+card:i = <http://graph.facebook.com/512908782#>.   # FB RDF feed from 2011/9
+
+
+### W3C's list of talks
+
+    card:i s:seeAlso <http://www.w3.org/2007/11/Talks/search/query?date=All+past+and+future+talks&event=None&activity=None&name=Tim+Berners-Lee&country=None&language=None&office=None&rdfOnly=yes&submit=Submit>.
+
+##### My Web ID cert
+
+card:i is cert:identity of [ 
+    a rsa:RSAPublicKey;
+    rsa:public_exponent "65537"^cert:decimal ;
+    rsa:modulus
+
+        """d7 a0 e9 1e ed dd cc 90 5d 5e cc d1 e4 12 ab 0c 
+5b db e1 18 fa 99 b7 13 2d 91 54 52 f0 b0 9a f5 
+eb c0 09 6c a1 db de ec 32 72 3f 5d dd 2b 05 56 
+4e 2c e6 7e ff ba 8e 86 77 8e 11 4a 02 a3 90 7c 
+2e 6c 6b 28 cf 16 fe e7 7d 0e f0 c4 4d 2e 3c cd 
+3e 0b 6e 8c fd d1 97 e3 aa 86 ec 19 99 80 72 9a 
+f4 45 1f 79 99 bc e5 5e b3 4b d5 a5 35 04 70 46 
+37 00 f7 30 8e 37 2b db 6e 07 5e 0b b8 a8 db a9 
+36 86 fa 4a e5 13 17 a4 43 82 bb 09 d0 92 94 c1 
+68 5b 10 97 ff d5 9c 44 6a e5 67 fa ec e6 b6 aa 
+27 89 79 06 b5 24 a6 49 89 bd 48 cf ea ec 61 d1 
+2c c0 b6 3d db 88 5d 2d ad b0 b3 58 c6 66 aa 93 
+f5 a4 43 fb 91 fc 2a 3d c6 99 eb 46 15 9b 05 c5 
+75 8c 9f 13 ed 28 44 09 4c c5 39 e5 82 e1 1d e3 
+6c 67 33 a6 7b 51 25 ef 40 7b 32 9e f5 e9 22 ca 
+57 46 a5 ff c6 7b 65 0b 4a e3 66 10 fc a0 cd 7b"""^cert:hex ;
+          ] .
+
+
+#old cert modulus:
+#"84554e39b67f5e3912068773655d855d222fa2c05cd9784693f8919aa46a61be703069c5f3266eebc21d6bb429ee47fac347b012eb7d#a8b1e4b02f7680e39767b0086f1fd48b9a420de3e70df9c2504c87006e7722ab6df210dec768dae454e65b31752379d7032dd22696465#62593d8b5c621860a0f929ad64b9dce1d6cb12f"^cert:hex ;
+
+
+
+
+
+
+##### Things I am involved in -- DOAP
+
+card:i is doap:developer of <http://www.w3.org/2000/10/swap/data#Cwm>,
+    <http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator>.
+
+
+# BBC Catalogue links:   # Clumsy .. need to give people URIs. Now offline :-(
+# card:i foaf:homepage <http://open.bbc.co.uk/catalogue/infax/contributor/169456>;
+#	s:seeAlso <http://open.bbc.co.uk/catalogue/xml/contributor/169456>.
+
+
+#  Advogato is geek social netorking site (2008)
+card:i = <http://www.advogato.org/person/timbl/foaf.rdf#me>.
+
+##### Identi.ca identity
+card:i = <http://identi.ca/user/45563>.
+
+#  The (2006/11) DBLP database
+card:i = <http://www4.wiwiss.fu-berlin.de/dblp/resource/person/100007>.
+
+# Bizer et al's  RDF mashup of Amazon
+card:i = <http://www4.wiwiss.fu-berlin.de/bookmashup/persons/Tim+Berners-Lee>.
+
+<http://www4.wiwiss.fu-berlin.de/booksMeshup/books/006251587X> dc:title
+"Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web";
+    dc:creator card:i.
+
+# More from Chris Bizer: the dbpedia scrape of Wikipedia
+#   @@@ Commented out temporaily as it was getting slow from redirecting each ontology term
+# <http://dbpedia.org/resource/Tim_Berners-Lee> = card:i.
+
+# MIT IAP course
+
+<http://dig.csail.mit.edu/2007/01/camp/data#course> foaf:maker card:i.
+
+# WWW2006 stuff:
+#  <#i>   = http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#tim_berners-lee
+#	
+
+
+
+####### 2011  WW2011
+
+<http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk>
+    dct:title "Designing the Web for an Open Society";
+    foaf:maker card:i.
+
+<http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01>
+	s:label  "The Next Wave of the Web (Plenary Panel)";
+	:participant card:i.
+
+<http://wiki.ontoworld.org/index.php/_IRW2006>
+	:participant card:i.
+ 
+<http://wiki.ontoworld.org/index.php/_IRW2006> 
+    dc:title "Identity, Reference and the Web workshop 2006".
+    
+<http://dig.csail.mit.edu/breadcrumbs/blog/4>
+    rdfs:seeAlso <http://dig.csail.mit.edu/breadcrumbs/blog/feed/4>; # Sigh
+    dc:title "timbl's blog";
+    is foaf:weblog of card:i;
+    foaf:maker card:i.
+    
+<../../DesignIssues/Overview.html>   #  Has RDFA in it
+    dc:title "Design Issues for the World Wide Web";
+    foaf:maker card:i.
+    
+#ends
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/card.rdf	Mon Nov 21 13:31:35 2011 -0500
@@ -0,0 +1,161 @@
+
+<!-- Processed by Id: cwm.py,v 1.197 2007/12/13 15:38:39 syosi Exp -->
+<!--     using base file:///devel/WWW/People/Berners-Lee/card.n3-->
+
+
+<rdf:RDF xmlns="http://xmlns.com/foaf/0.1/"
+    xmlns:cc="http://creativecommons.org/ns#"
+    xmlns:cert="http://www.w3.org/ns/auth/cert#"
+    xmlns:con="http://www.w3.org/2000/10/swap/pim/contact#"
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:dct="http://purl.org/dc/terms/"
+    xmlns:doap="http://usefulinc.com/ns/doap#"
+    xmlns:foaf="http://xmlns.com/foaf/0.1/"
+    xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
+    xmlns:owl="http://www.w3.org/2002/07/owl#"
+    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns:rsa="http://www.w3.org/ns/auth/rsa#"
+    xmlns:s="http://www.w3.org/2000/01/rdf-schema#">
+
+    <rdf:Description rdf:about="../../DesignIssues/Overview.html">
+        <dc:title>Design Issues for the World Wide Web</dc:title>
+        <maker rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <PersonalProfileDocument rdf:about="">
+        <cc:license rdf:resource="http://creativecommons.org/licenses/by-nc/3.0/"/>
+        <dc:title>Tim Berners-Lee's FOAF file</dc:title>
+        <maker rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+        <primaryTopic rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </PersonalProfileDocument>
+
+    <rdf:Description rdf:about="http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator">
+        <doap:developer rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <rdf:Description rdf:about="http://dig.csail.mit.edu/2007/01/camp/data#course">
+        <maker rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <PersonalProfileDocument rdf:about="http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf">
+        <cc:license rdf:resource="http://creativecommons.org/licenses/by-nc/3.0/"/>
+        <dc:title>Tim Berners-Lee's editable FOAF file</dc:title>
+        <maker rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+        <primaryTopic rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </PersonalProfileDocument>
+
+    <rdf:Description rdf:about="http://dig.csail.mit.edu/breadcrumbs/blog/4">
+        <dc:title>timbl's blog</dc:title>
+        <s:seeAlso rdf:resource="http://dig.csail.mit.edu/breadcrumbs/blog/feed/4"/>
+        <maker rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <rdf:Description rdf:about="http://dig.csail.mit.edu/data#DIG">
+        <member rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <rdf:Description rdf:about="http://wiki.ontoworld.org/index.php/_IRW2006">
+        <dc:title>Identity, Reference and the Web workshop 2006</dc:title>
+        <con:participant rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <rdf:Description rdf:about="http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01">
+        <s:label>The Next Wave of the Web (Plenary Panel)</s:label>
+        <con:participant rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <rdf:Description rdf:about="http://www.w3.org/2000/10/swap/data#Cwm">
+        <doap:developer rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <rdf:Description rdf:about="http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk">
+        <dct:title>Designing the Web for an Open Society</dct:title>
+        <maker rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <con:Male rdf:about="http://www.w3.org/People/Berners-Lee/card#i">
+        <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
+        <s:label>Tim Berners-Lee</s:label>
+        <s:seeAlso rdf:resource="http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf"/>
+        <s:seeAlso rdf:resource="http://www.w3.org/2007/11/Talks/search/query?date=All+past+and+future+talks&#38;event=None&#38;activity=None&#38;name=Tim+Berners-Lee&#38;country=None&#38;language=None&#38;office=None&#38;rdfOnly=yes&#38;submit=Submit"/>
+        <con:assistant rdf:resource="http://www.w3.org/People/Berners-Lee/card#amy"/>
+        <con:homePage rdf:resource="./"/>
+        <con:office rdf:parseType="Resource">
+            <con:address rdf:parseType="Resource">
+                <con:city>Cambridge</con:city>
+                <con:country>USA</con:country>
+                <con:postalCode>02139</con:postalCode>
+                <con:street>32 Vassar Street</con:street>
+                <con:street2>MIT CSAIL Room 32-G524</con:street2>
+            </con:address>
+            <con:phone rdf:resource="tel:+1-617-253-5702"/>
+            <geo:location rdf:parseType="Resource">
+                <geo:lat>42.361860</geo:lat>
+                <geo:long>-71.091840</geo:long>
+            </geo:location>
+        </con:office>
+        <con:preferredURI>http://www.w3.org/People/Berners-Lee/card#i</con:preferredURI>
+        <con:publicHomePage rdf:resource="./"/>
+        <owl:sameAs rdf:resource="http://graph.facebook.com/512908782#"/>
+        <owl:sameAs rdf:resource="http://identi.ca/user/45563"/>
+        <owl:sameAs rdf:resource="http://www.advogato.org/person/timbl/foaf.rdf#me"/>
+        <owl:sameAs rdf:resource="http://www4.wiwiss.fu-berlin.de/bookmashup/persons/Tim+Berners-Lee"/>
+        <owl:sameAs rdf:resource="http://www4.wiwiss.fu-berlin.de/dblp/resource/person/100007"/>
+        <account rdf:resource="http://en.wikipedia.org/wiki/User:Timbl"/>
+        <account rdf:resource="http://identi.ca/timbl"/>
+        <account rdf:resource="http://twitter.com/timberners_lee"/>
+        <based_near rdf:parseType="Resource">
+            <geo:lat>42.361860</geo:lat>
+            <geo:long>-71.091840</geo:long>
+        </based_near>
+        <family_name>Berners-Lee</family_name>
+        <givenname>Timothy</givenname>
+        <homepage rdf:resource="http://www.w3.org/People/Berners-Lee/"/>
+        <img rdf:resource="http://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg"/>
+        <mbox rdf:resource="mailto:timbl@w3.org"/>
+        <mbox_sha1sum>965c47c5a70db7407210cef6e4e6f5374a525c5c</mbox_sha1sum>
+        <name>Timothy Berners-Lee</name>
+        <nick>TimBL</nick>
+        <nick>timbl</nick>
+        <openid rdf:resource="http://www.w3.org/People/Berners-Lee/"/>
+        <phone rdf:resource="tel:+1-(617)-253-5702"/>
+        <title>Sir</title>
+        <weblog rdf:resource="http://dig.csail.mit.edu/breadcrumbs/blog/4"/>
+        <workplaceHomepage rdf:resource="http://www.w3.org/"/>
+    </con:Male>
+
+    <rdf:Description rdf:about="http://www.w3.org/data#W3C">
+        <member rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+    </rdf:Description>
+
+    <rdf:Description rdf:about="http://www4.wiwiss.fu-berlin.de/booksMeshup/books/006251587X">
+        <dc:creator rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+        <dc:title>Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web</dc:title>
+    </rdf:Description>
+
+    <rdf:Description>
+        <rdf:type rdf:resource="http://www.w3.org/ns/auth/rsa#RSAPublicKey"/>
+        <cert:identity rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
+        <rsa:modulus rdf:parseType="Resource">
+            <cert:hex>d7 a0 e9 1e ed dd cc 90 5d 5e cc d1 e4 12 ab 0c 
+5b db e1 18 fa 99 b7 13 2d 91 54 52 f0 b0 9a f5 
+eb c0 09 6c a1 db de ec 32 72 3f 5d dd 2b 05 56 
+4e 2c e6 7e ff ba 8e 86 77 8e 11 4a 02 a3 90 7c 
+2e 6c 6b 28 cf 16 fe e7 7d 0e f0 c4 4d 2e 3c cd 
+3e 0b 6e 8c fd d1 97 e3 aa 86 ec 19 99 80 72 9a 
+f4 45 1f 79 99 bc e5 5e b3 4b d5 a5 35 04 70 46 
+37 00 f7 30 8e 37 2b db 6e 07 5e 0b b8 a8 db a9 
+36 86 fa 4a e5 13 17 a4 43 82 bb 09 d0 92 94 c1 
+68 5b 10 97 ff d5 9c 44 6a e5 67 fa ec e6 b6 aa 
+27 89 79 06 b5 24 a6 49 89 bd 48 cf ea ec 61 d1 
+2c c0 b6 3d db 88 5d 2d ad b0 b3 58 c6 66 aa 93 
+f5 a4 43 fb 91 fc 2a 3d c6 99 eb 46 15 9b 05 c5 
+75 8c 9f 13 ed 28 44 09 4c c5 39 e5 82 e1 1d e3 
+6c 67 33 a6 7b 51 25 ef 40 7b 32 9e f5 e9 22 ca 
+57 46 a5 ff c6 7b 65 0b 4a e3 66 10 fc a0 cd 7b</cert:hex>
+        </rsa:modulus>
+        <rsa:public_exponent rdf:parseType="Resource">
+            <cert:decimal>65537</cert:decimal>
+        </rsa:public_exponent>
+    </rdf:Description>
+</rdf:RDF>