[isidorus-cvs] r117 - in trunk/src: . model unit_tests xml/rdf

Lukas Giessmann lgiessmann at common-lisp.net
Mon Aug 24 16:37:41 UTC 2009


Author: lgiessmann
Date: Mon Aug 24 12:37:40 2009
New Revision: 117

Log:
rdf-exporter: implemented a part of the rdf-exporter. currently associations, that do not represent type-instance or supertype-subtype associations are not exported; unit tests are not implemented at the moment, there is just a test file which can be xported "poems_light.xtm"

Added:
   trunk/src/unit_tests/poems_light.xtm
Modified:
   trunk/src/constants.lisp
   trunk/src/isidorus.asd
   trunk/src/model/datamodel.lisp
   trunk/src/unit_tests/poems.rdf
   trunk/src/unit_tests/poems_light.rdf
   trunk/src/unit_tests/rdf_importer_test.lisp
   trunk/src/xml/rdf/exporter.lisp
   trunk/src/xml/rdf/importer.lisp
   trunk/src/xml/rdf/rdf_core_psis.xtm
   trunk/src/xml/rdf/rdf_tools.lisp

Modified: trunk/src/constants.lisp
==============================================================================
--- trunk/src/constants.lisp	(original)
+++ trunk/src/constants.lisp	Mon Aug 24 12:37:40 2009
@@ -27,6 +27,7 @@
 	   :*xml-ns*
 	   :*xmlns-ns*
 	   :*xml-string*
+	   :*xml-uri*
 	   :*rdf2tm-ns*
 	   :*rdf-statement*
 	   :*rdf-object*
@@ -37,7 +38,8 @@
 	   :*rdf-rest*
 	   :*rdf2tm-object*
 	   :*rdf2tm-subject*
-	   :*rdf2tm-scope-prefix*))
+	   :*rdf2tm-scope-prefix*
+	   :*tm2rdf-ns*))
 
 (in-package :constants)
 (defparameter *xtm2.0-ns* "http://www.topicmaps.org/xtm/")
@@ -74,7 +76,9 @@
 
 (defparameter *xml-string* "http://www.w3.org/2001/XMLSchema#string")
 
-(defparameter *rdf2tm-ns* "http://isidorus/rdf2tm_mapping#")
+(defparameter *xml-uri* "http://www.w3.org/2001/XMLSchema#anyURI")
+
+(defparameter *rdf2tm-ns* "http://isidorus/rdf2tm_mapping/")
 
 (defparameter *rdf-statement* "http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement")
 
@@ -90,8 +94,10 @@
 
 (defparameter *rdf-rest* "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest")
 
-(defparameter *rdf2tm-object* "http://isidorus/rdf2tm_mapping#object")
+(defparameter *rdf2tm-object* "http://isidorus/rdf2tm_mapping/object")
+
+(defparameter *rdf2tm-subject* "http://isidorus/rdf2tm_mapping/subject")
 
-(defparameter *rdf2tm-subject* "http://isidorus/rdf2tm_mapping#subject")
+(defparameter *rdf2tm-scope-prefix* "http://isidorus/rdf2tm_mapping/scope/")
 
-(defparameter *rdf2tm-scope-prefix* "http://isidorus/rdf2tm_mapping/scope#")
\ No newline at end of file
+(defparameter *tm2rdf-ns* "http://isidorus/tm2rdf_mapping/")
\ No newline at end of file

Modified: trunk/src/isidorus.asd
==============================================================================
--- trunk/src/isidorus.asd	(original)
+++ trunk/src/isidorus.asd	Mon Aug 24 12:37:40 2009
@@ -107,6 +107,7 @@
 				     (:static-file "poems.xtm")
 				     (:static-file "poems.rdf")
 				     (:static-file "poems_light.rdf")
+				     (:static-file "poems_light.xtm")
 				     (:file "atom-conf")
 				     (:file "unittests-constants"
 					    :depends-on ("dangling_topicref.xtm"

Modified: trunk/src/model/datamodel.lisp
==============================================================================
--- trunk/src/model/datamodel.lisp	(original)
+++ trunk/src/model/datamodel.lisp	Mon Aug 24 12:37:40 2009
@@ -66,6 +66,7 @@
            :item-identifiers
            :item-identifiers-p
            :list-instanceOf
+	   :list-super-types
            :locators
            :locators-p
            :make-construct
@@ -105,6 +106,8 @@
            :*TM-REVISION*
 
            :with-revision ;;macros
+
+	   :string-starts-with ;;helpers
            ))
 
 (declaim (optimize (debug 3) (safety 3) (speed 0) (space 0)))
@@ -647,7 +650,6 @@
                 (elephant:get-instances-by-value 'PersistentIdC 'uri (uri id))
                 (elephant:get-instances-by-value 'SubjectLocatorC 'uri (uri id)))))
              1)
-      ;(format t "cfdi: ~A --> ~A~%" construct (item-identifiers construct))
       (error 
        (make-condition 'duplicate-identifier-error 
                        :message (format nil "Duplicate Identifier ~a has been found" (uri id))
@@ -1174,6 +1176,33 @@
              (player-in-roles topic))
             (player-in-roles topic)))))
 
+
+(defgeneric list-super-types (topic &key tm)
+ (:documentation "Generate a list of all topics that this topic is an
+  subclass of, optionally filtered by a topic map"))
+
+
+(defmethod list-super-types ((topic TopicC)  &key (tm nil))
+  (remove-if 
+   #'null
+   (map 'list #'(lambda(x)
+                  (when (loop for psi in (psis (instance-of x))
+                           when (string= (uri psi) *subtype-psi*)
+                           return t)
+                    (loop for role in (roles (parent x))
+                       when (not (eq role x))
+                       return (player role))))
+        (if tm
+            (remove-if-not 
+             (lambda (role)
+               (format t "player: ~a" (player role))
+               (format t "parent: ~a" (parent role))
+               (format t "topic: ~a~&" topic)
+               (in-topicmap tm (parent role)))
+             (player-in-roles topic))
+            (player-in-roles topic)))))
+
+
 (defun string-starts-with (str prefix)
   "Checks if string str starts with a given prefix"
   (declare (string str prefix))

Modified: trunk/src/unit_tests/poems.rdf
==============================================================================
--- trunk/src/unit_tests/poems.rdf	(original)
+++ trunk/src/unit_tests/poems.rdf	Mon Aug 24 12:37:40 2009
@@ -248,8 +248,8 @@
 	<rdf:type rdf:resource="/types/Poem"/>
 	<arcs:dateRange>
 	  <rdf:Description xml:base="http://does.not.exist">
-	    <arcs:start rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1772</arcs:start>
-	    <arcs:end rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1774</arcs:end>
+	    <arcs:start rdf:datatype="http://www.w3.org/2001/XMLSchema#date">01.01.1772</arcs:start>
+	    <arcs:end rdf:datatype="http://www.w3.org/2001/XMLSchema#date">31.12.1774</arcs:end>
 	  </rdf:Description>
 	</arcs:dateRange>
 	<arcs:content rdf:parseType="Literal" xml:lang="de">

Modified: trunk/src/unit_tests/poems_light.rdf
==============================================================================
--- trunk/src/unit_tests/poems_light.rdf	(original)
+++ trunk/src/unit_tests/poems_light.rdf	Mon Aug 24 12:37:40 2009
@@ -73,119 +73,7 @@
 	      <arcs:start rdf:datatype="#date">01.01.1797</arcs:start>
 	      <arcs:end rdf:datatype="#date">31.12.1797</arcs:end>
 	    </arcs:dateRange>
-	    <arcs:content xml:lang="de">
-	      <![CDATA[Hat der alte Hexenmeister
-sich doch einmal wegbegeben!
-Und nun sollen seine Geister
-auch nach meinem Willen leben.
-Seine Wort und Werke
-merkt ich und den Brauch,
-und mit Geistesstärke
-tu ich Wunder auch.
-
-Walle! walle
-Manche Strecke,
-daß, zum Zwecke,
-Wasser fließe
-und mit reichem, vollem Schwalle
-zu dem Bade sich ergieße.
-
-Und nun komm, du alter Besen!
-Nimm die schlechten Lumpenhüllen;
-bist schon lange Knecht gewesen:
-nun erfülle meinen Willen!
-Auf zwei Beinen stehe,
-oben sei ein Kopf,
-eile nun und gehe
-mit dem Wassertopf!
-
-Walle! walle
-manche Strecke,
-daß, zum Zwecke,
-Wasser fließe
-und mit reichem, vollem Schwalle
-zu dem Bade sich ergieße.
-
-Seht, er läuft zum Ufer nieder,
-Wahrlich! ist schon an dem Flusse,
-und mit Blitzesschnelle wieder
-ist er hier mit raschem Gusse.
-Schon zum zweiten Male!
-Wie das Becken schwillt!
-Wie sich jede Schale
-voll mit Wasser füllt!
-
-Stehe! stehe!
-denn wir haben
-deiner Gaben
-vollgemessen! -
-Ach, ich merk es! Wehe! wehe!
-Hab ich doch das Wort vergessen!
-
-Ach, das Wort, worauf am Ende
-er das wird, was er gewesen.
-Ach, er läuft und bringt behende!
-Wärst du doch der alte Besen!
-Immer neue Güsse
-bringt er schnell herein,
-Ach! und hundert Flüsse
-stürzen auf mich ein.
-
-Nein, nicht länger
-kann ichs lassen;
-will ihn fassen.
-Das ist Tücke!
-Ach! nun wird mir immer bänger!
-Welche Mine! welche Blicke!
-
-O du Ausgeburt der Hölle!
-Soll das ganze Haus ersaufen?
-Seh ich über jede Schwelle
-doch schon Wasserströme laufen.
-Ein verruchter Besen,
-der nicht hören will!
-Stock, der du gewesen,
-steh doch wieder still!
-
-Willst am Ende
-gar nicht lassen?
-Will dich fassen,
-will dich halten
-und das alte Holz behende
-mit dem scharfen Beile spalten.
-
-Seht da kommt er schleppend wieder!
-Wie ich mich nur auf dich werfe,
-gleich, o Kobold, liegst du nieder;
-krachend trifft die glatte Schärfe.
-Wahrlich, brav getroffen!
-Seht, er ist entzwei!
-Und nun kann ich hoffen,
-und ich atme frei!
-
-Wehe! wehe!
-Beide Teile
-stehn in Eile
-schon als Knechte
-völlig fertig in die Höhe!
-Helft mir, ach! ihr hohen Mächte!
-
-Und sie laufen! Naß und nässer
-wirds im Saal und auf den Stufen.
-Welch entsetzliches Gewässer!
-Herr und Meister! hör mich rufen! -
-Ach, da kommt der Meister!
-Herr, die Not ist groß!
-Die ich rief, die Geister
-werd ich nun nicht los.
-
-"In die Ecke,
-Besen, Besen!
-Seids gewesen.
-Denn als Geister
-ruft euch nur zu diesem Zwecke,
-erst hervor der alte Meister."]]>
-	    </arcs:content>
+	    <arcs:content xml:lang="de"><![CDATA[Hat der alte Hexenmeister ...]]></arcs:content>
 	  </types:Poem>
 	</rdf:li>
       </rdf:Bag>
@@ -200,47 +88,7 @@
 	  <arcs:start rdf:datatype="#date">01.01.1782</arcs:start>
 	  <arcs:end  rdf:datatype="#date">31.12.1782</arcs:end>
 	</arcs:dateRange>
-	<arcs:content rdf:datatype="http://www.w3.org/2001/XMLSchema#string" xml:lang="de">
-	  <![CDATA[Wer reitet so spät durch Nacht und Wind?
-Es ist der Vater mit seinem Kind;
-Er hat den Knaben wohl in dem Arm,
-Er faßt ihn sicher, er hält ihn warm.
-
-Mein Sohn, was birgst du so bang dein Gesicht? -
-Siehst Vater, du den Erlkönig nicht?
-Den Erlenkönig mit Kron und Schweif? -
-Mein Sohn, es ist ein Nebelstreif. -
-
-"Du liebes Kind, komm, geh mit mir!
-Gar schöne Spiele spiel ich mit dir;
-Manch bunte Blumen sind an dem Strand,
-Meine Mutter hat manch gülden Gewand."
-
-Mein Vater, mein Vater, und hörest du nicht,
-Was Erlenkönig mir leise verspricht? -
-Sei ruhig, bleibe ruhig, mein Kind;
-In dürren Blättern säuselt der Wind. -
-
-"Willst, feiner Knabe, du mit mir gehn?
-Meine Töchter sollen dich warten schön;
-Meine Töchter führen den nächtlichen Reihn
-Und wiegen und tanzen und singen dich ein."
-
-Mein Vater, mein Vater, und siehst du nicht dort
-Erlkönigs Töchter am düstern Ort? -
-Mein Sohn, mein Sohn, ich seh es genau:
-Es scheinen die alten Weiden so grau. -
-
-"Ich liebe dich, mich reizt deine schöne Gestalt;
-Und bist du nicht willig, so brauch ich Gewalt."
-Mein Vater, mein Vater, jetzt faßt er mich an!
-Erlkönig hat mir ein Leids getan! -
-
-Dem Vater grauset's, er reitet geschwind,
-Er hält in den Armen das ächzende Kind,
-Erreicht den Hof mit Mühe und Not;
-In seinen Armen das Kind war tot.]]>
-	</arcs:content>
+	<arcs:content rdf:datatype="http://www.w3.org/2001/XMLSchema#string" xml:lang="de">Wer reitet so spät durch Nacht und Wind? ...</arcs:content>
       </types:Ballad>
     </rdf:li>
     <rdf:li>
@@ -248,76 +96,11 @@
 	<rdf:type rdf:resource="/types/Poem"/>
 	<arcs:dateRange>
 	  <rdf:Description xml:base="http://does.not.exist">
-	    <arcs:start rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1772</arcs:start>
-	    <arcs:end rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1774</arcs:end>
+	    <arcs:start rdf:datatype="http://www.w3.org/2001/XMLSchema#date">01.01.1772</arcs:start>
+	    <arcs:end rdf:datatype="http://www.w3.org/2001/XMLSchema#date">31.12.1774</arcs:end>
 	  </rdf:Description>
 	</arcs:dateRange>
-	<arcs:content rdf:parseType="Literal" xml:lang="de">
-	  <![CDATA[Bedecke deinen Himmel, Zeus,
-Mit Wolkendunst!
-Und übe, Knaben gleich,
-Der Disteln köpft,
-An Eichen dich und Bergeshöh'n!
-Mußt mir meine Erde
-Doch lassen steh'n,
-Und meine Hütte,
-Die du nicht gebaut,
-Und meinen Herd,
-Um dessen Glut
-Du mich beneidest.
-
-Ich kenne nichts Ärmeres
-Unter der Sonn' als euch Götter!
-Ihr nähret kümmerlich
-Von Opfersteuern
-Und Gebetshauch
-Eure Majestät
-Und darbtet, wären
-Nicht Kinder und Bettler
-Hoffnungsvolle Toren.
-
-Da ich ein Kind war,
-Nicht wußte, wo aus, wo ein,
-Kehrt' ich mein verirrtes Auge
-Zur Sonne, als wenn drüber wär
-Ein Ohr zu hören meine Klage,
-Ein Herz wie meins,
-Sich des Bedrängten zu erbarmen.
-
-Wer half mir
-Wider der Titanen Übermut?
-Wer rettete vom Tode mich,
-Von Sklaverei?
-Hast du's nicht alles selbst vollendet,
-Heilig glühend Herz?
-Und glühtest, jung und gut,
-Betrogen, Rettungsdank
-Dem Schlafenden dadroben?
-
-Ich dich ehren? Wofür?
-Hast du die Schmerzen gelindert
-Je des Beladenen?
-Hast du die Tränen gestillet
-Je des Geängsteten?
-Hat nicht mich zum Manne geschmiedet
-Die allmächtige Zeit
-Und das ewige Schicksal,
-Meine Herren und deine?
-
-Wähntest du etwa,
-Ich sollte das Leben hassen,
-In Wüsten fliehn,
-Weil nicht alle Knabenmorgen-
-Blütenträume reiften?
-
-Hier sitz' ich, forme Menschen
-Nach meinem Bilde,
-Ein Geschlecht, das mir gleich sei,
-Zu leiden, weinen,
-Genießen und zu freuen sich,
-Und dein nicht zu achten,
-Wie ich!]]>
-	</arcs:content>
+	<arcs:content rdf:parseType="Literal" xml:lang="de"><![CDATA[ Bedecke deinen Himmel, Zeus, ... ]]></arcs:content>
       </rdf:Description>
     </rdf:li>
   </rdf:Description>

Added: trunk/src/unit_tests/poems_light.xtm
==============================================================================
--- (empty file)
+++ trunk/src/unit_tests/poems_light.xtm	Mon Aug 24 12:37:40 2009
@@ -0,0 +1,578 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tm:topicMap version="2.0" xmlns:tm="http://www.topicmaps.org/xtm/">
+  <!-- this file contains constructs that are originally defined as TM and
+       RDF, so certain constructs are not consistent because of test cases -->
+  <tm:topic id="goethe">
+    <tm:subjectIdentifier href="http://some.where/author/Goehte"/>
+    <tm:instanceOf><tm:topicRef href="#author"/></tm:instanceOf>
+    <tm:name>
+      <tm:type><tm:topicRef href="#firstName"/></tm:type>
+      <tm:value>Johann Wolfgang</tm:value>
+    </tm:name>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#lastName"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">von Goethe</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="UUID-born-event">
+    <tm:instanceOf href="#event"/>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#date"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">28.08.1749</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="frankfurt_m">
+    <tm:subjectIdentifier href="http://some.where/metropolis/FrankfurtMain"/>
+    <tm:instanceOf><tm:topicRef href="#metropolis"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#population"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">659000</tm:resourceData>
+    </tm:occurrence>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#fullName"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Frankfurt am Main</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="germany">
+    <tm:subjectIdentifier href="http://some.where/country/Germany"/>
+    <tm:instanceOf><tm:topicRef href="#country"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#nativeName"/></tm:type>
+      <tm:scope><tm:topicRef href="#de"/></tm:scope>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Deutschland</tm:resourceData>
+    </tm:occurrence>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#population"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">82099232</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="berlin">
+    <tm:subjectIdentifier href="http://some.where/metropolis/Berlin"/>
+    <tm:instanceOf><tm:topicRef href="#metropolis"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#population"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">3431473</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="UUID-died-event">
+    <tm:instanceOf><tm:topicRef href="#event"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#date"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">22.03.1832</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="weimar">
+    <tm:subjectIdentifier href="http://some.where/city/Weimar"/>
+    <tm:instanceOf><tm:topicRef href="#city"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#population"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">64720</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="zauberlehrling">
+    <tm:subectIdentifier href="http://some.where/poem/Der_Zauberlehrling"/>
+    <tm:subectIdentifier href="http://some.where/poem/Zauberlehrling"/>
+    <tm:itemIdentity href="http://some.where/poem/Zauberlehrling_itemIdentity"/>
+    <tm:subjectLocator href="http://some.where/resource"/>
+    <tm:instanceOf><tm:topicRef href="#poem"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#title"/></tm:type>
+      <tm:scope>
+	<tm:topicRef href="#de"/>
+	<tm:topicRef href="#en"/>
+      </tm:scope>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Der Zauberlehrling</tm:resourceData>
+    </tm:occurrence>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#content"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Hat der alte Hexenmeister ...</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="UUID-dateRange-1">
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#start"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">01.01.1797</tm:resourceData>
+    </tm:occurrence>
+        <tm:occurrence>
+      <tm:type><tm:topicRef href="#end"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">31.12.1797</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="erlkoenig">
+    <tm:subjectIdentifier href="http://some.where/ballad/Der_Erlkoenig"/>
+    <tm:instanceOf><tm:topicRef href="#ballad"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#title"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Der Erlkönig</tm:resourceData>
+      <tm:scope><tm:topicRef href="#en"/></tm:scope>
+    </tm:occurrence>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#content"/></tm:type>
+      <tm:scope><tm:topicRef href="#de"/></tm:scope>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Wer reitet so spät durch Nacht und Wind? ...</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="UUID-dateRange-2">
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#start"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">01.01.1782</tm:resourceData>
+    </tm:occurrence>
+        <tm:occurrence>
+      <tm:type><tm:topicRef href="#end"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">31.12.1782</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="prometheus">
+    <tm:subjectIdentifier href="http://some.where/ballad/Prometheus"/>
+    <tm:instanceOf><tm:topicRef href="#poem"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#title"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Prometheus</tm:resourceData>
+      <tm:scope><tm:topicRef href="#de"/></tm:scope>
+    </tm:occurrence>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#content"/></tm:type>
+      <tm:scope><tm:topicRef href="#de"/></tm:scope>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string"> Bedecke deinen Himmel, Zeus, ... </tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="UUID-dateRange-3">
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#start"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">01.01.1772</tm:resourceData>
+    </tm:occurrence>
+        <tm:occurrence>
+      <tm:type><tm:topicRef href="#end"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#date">31.12.1774</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:topic id="dateRange">
+    <tm:subjectIdentifier href="http://some.where/relationship/dateRange"/>
+  </tm:topic>
+
+  <tm:topic id="officialese">
+    <tm:subjectIdentifier href="http://some.where/relationship/officialese"/>
+  </tm:topic>
+
+  <tm:topic id="content">
+    <tm:subjectIdentifier href="http://some.where/relationship/content"/>
+  </tm:topic>
+
+  <tm:topic id="start">
+    <tm:subjectIdentifier href="http://some.where/relationship/start"/>
+  </tm:topic>
+
+  <tm:topic id="end">
+    <tm:subjectIdentifier href="http://some.where/relationship/end"/>
+  </tm:topic>
+
+  <tm:topic id="de">
+    <tm:subjectIdentifier href="http://isidorus/rdf2tm_mapping/scope/de"/>
+  </tm:topic>
+
+  <tm:topic id="en">
+    <tm:subjectIdentifier href="http://some.where/scope/en"/>
+  </tm:topic>
+
+  <tm:topic id="title">
+    <tm:subjetcIdentifier href="http://some.where/relationship/title"/>
+  </tm:topic>
+
+  <tm:topic id="poem">
+    <tm:subjectIdentifier href="http://some.where/types/Poem"/>
+  </tm:topic>
+
+  <tm:topic id="ballad">
+    <tm:subjectIdentifier href="http://some.where/types/Ballad"/>
+  </tm:topic>
+
+  <tm:topic id="supertype-subtype">
+    <tm:subjectIdentifier href="http://psi.topicmaps.org/iso13250/model/supertype-subtype"/>
+  </tm:topic>
+
+  <tm:topic id="supertype">
+    <tm:subjectIdentifier href="http://psi.topicmaps.org/iso13250/model/supertype"/>
+  </tm:topic>
+
+  <tm:topic id="subtype">
+    <tm:subjectIdentifier href="http://psi.topicmaps.org/iso13250/model/subtype"/>
+  </tm:topic>
+
+  <tm:topic id="region">
+    <tm:subjectIdentifier href="http://some.where/types/Region"/>
+  </tm:topic>
+
+  <tm:topic id="city">
+    <tm:subjectIdentifier href="http://some.where/types/City"/>
+  </tm:topic>
+
+  <tm:topic id="died">
+    <tm:subjectIdentifier href="http://some.where/relationship/died"/>
+  </tm:topic>
+
+  <tm:topic id="capital">
+    <tm:subjectIdentifier href="http://some.where/relationship/capital"/>
+  </tm:topic>
+
+  <tm:topic id="german">
+    <tm:subjectIdentifier href="http://some.where/language/German"/>
+    <tm:instanceOf><tm:topicRef href="#language"/></tm:instanceOf>
+  </tm:topic>
+
+  <tm:topic id="language">
+    <tm:subjectIdentifier href="http://some.where/types/Language"/>
+  </tm:topic>
+
+  <tm:topic id="population">
+    <tm:subjectIdentifier href="http://some.where/relationship/population"/>
+  </tm:topic>
+
+  <tm:topic id="nativeName">
+    <tm:subjectIdentifier href="http://some.where/relationship/nativeName"/>
+  </tm:topic>
+
+  <tm:topic id="country">
+    <tm:subjectIdentifier href="http://some.where/types/Country"/>
+  </tm:topic>
+
+  <tm:topic id="metropolis">
+    <tm:subjectIdentifier href="http://some.where/types/Metropolis"/>
+  </tm:topic>
+
+  <tm:topic id="locatedIn">
+    <tm:subjectIdentifier href="http://some.where/relationship/locatedIn"/>
+  </tm:topic>
+
+  <tm:topic id="place">
+    <tm:subjectIdentifier href="http://some.where/relationship/place"/>
+  </tm:topic>
+
+  <tm:topic id="fullName">
+    <tm:subjectIdentifier href="http://some.where/relationship/fullName"/>
+  </tm:topic>
+
+  <tm:topic id="date">
+    <tm:subjectIdentifier href="http://some.where/relationship/date"/>
+  </tm:topic>
+
+  <tm:topic id="born">
+    <tm:subjectIdentifier href="http://some.where/relationship/born"/>
+  </tm:topic>
+
+  <tm:topic id="author">
+    <tm:subjectIdentifier href="http://some.where/types/Author"/>
+  </tm:topic>
+
+  <tm:topic id="firstName">
+    <tm:subjectIdentifier href="http://some.where/relationship/firstName"/>
+  </tm:topic>
+
+  <tm:topic id="lastName">
+    <tm:subjectIdentifier href="http://some.where/relationsip/lastName"/>
+  </tm:topic>
+
+  <tm:topic id="event">
+    <tm:subjectIdentifier href="http://some.where/types/Event"/>
+  </tm:topic>
+
+  <tm:topic id="isi-subject">
+    <tm:subjectIdentifier href="http://isidorus/rdf2tm_mapping/subject"/>
+  </tm:topic>
+
+  <tm:topic id="isi-object">
+    <tm:subjectIdentifier href="http://isidorus/rdf2tm_mapping/object"/>
+  </tm:topic>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#born"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#goethe"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-born-event"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#place"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-born-event"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#frankfurt_m"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#locatedIn"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#frankfurt_m"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#germany"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#officialese"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#germany"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#german"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#locatedIn"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#berlin"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#germany"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#capital"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#germany"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#berlin"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#died"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#goethe"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-died-event"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#place"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-died-event"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#weimar"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#locatedIn"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#weimar"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#germany"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#supertype-subtype"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#supertype"/></tm:type>
+      <tm:topicRef href="#region"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#subtype"/></tm:type>
+      <tm:topicRef href="#city"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:itemIdentity href="http://some.where/metropolis_supertye-subtype-association"/>
+    <tm:type><tm:topicRef href="#supertype-subtype"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#supertype"/></tm:type>
+      <tm:topicRef href="#region"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#subtype"/></tm:type>
+      <tm:topicRef href="#metropolis"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#dateRange"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#zauberlehrling"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-dateRange-1"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#dateRange"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#erlkoenig"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-dateRange-2"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#dateRange"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#prometheus"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-dateRange-3"/>
+    </tm:role>
+  </tm:association>
+
+  <!-- the rdf:li elements are contained as a collection, to test the export
+       of collections -->
+  <tm:topic id="wrote">
+    <tm:subjectIdentifier href="http://some.where/relationship/wrote"/>
+  </tm:topic>
+
+  <tm:topic id="rest">
+    <tm:subjectIdentifier href="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"/>
+  </tm:topic>
+
+  <tm:topic id="first">
+    <tm:subjectIdentifier href="http://www.w3.org/1999/02/22-rdf-syntax-ns#first"/>
+  </tm:topic>
+
+  <tm:topic id="nil">
+    <tm:subjectIdentifier href="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
+  </tm:topic>
+
+  <!-- first node -->
+  <tm:topic id="UUID-1-collection"/>
+  
+  <tm:association>
+    <tm:type><tm:topicRef href="#wrote"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#goethe"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-1-collection"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#first"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-1-collection"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#zauberlehrling"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#rest"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-1-collection"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-2-collection"/>
+    </tm:role>
+  </tm:association>
+  
+  <!-- second node -->
+  <tm:topic id="UUID-2-collection"/>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#first"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-2-collection"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#erlkoenig"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#rest"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-2-collection"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#UUID-3-collection"/>
+    </tm:role>
+  </tm:association>
+
+  <!-- third node -->
+  <tm:topic id="UUID-3-collection"/>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#first"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-3-collection"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#prometheus"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#rest"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-subject"/></tm:type>
+      <tm:topicRef href="#UUID-3-collection"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#isi-object"/></tm:type>
+      <tm:topicRef href="#nil"/>
+    </tm:role>
+  </tm:association>
+</tm:topicMap>
\ No newline at end of file

Modified: trunk/src/unit_tests/rdf_importer_test.lisp
==============================================================================
--- trunk/src/unit_tests/rdf_importer_test.lisp	(original)
+++ trunk/src/unit_tests/rdf_importer_test.lisp	Mon Aug 24 12:37:40 2009
@@ -1793,7 +1793,7 @@
 	  (prometheus "http://some.where/poem/Prometheus")
 	  (erlkoenig "http://some.where/ballad/Der_Erlkoenig")
 	  (date "http://www.w3.org/2001/XMLSchema#date")
-	  (de (d:get-item-by-id "http://isidorus/rdf2tm_mapping/scope#de"))
+	  (de (d:get-item-by-id "http://isidorus/rdf2tm_mapping/scope/de"))
 	  (long "http://www.w3.org/2001/XMLSchema#unsignedLong"))
       (is (= (length topics) 65))
       (is (= (length occs) 23))
@@ -1866,6 +1866,7 @@
 		       (string= (d:uri (first (d:psis (d:instance-of x))))
 				(concatenate 'string arcs "title"))
 		       (string= *xml-string* (d:datatype x))
+		       (string= (d:charvalue x) "Der Zauberlehrling")
 		       (= 1 (length (d:themes x)))
 		       (eql (first (d:themes x)) de)
 		       (= (length (d:psis (d:topic x))) 1)
@@ -1879,6 +1880,7 @@
 		       (string= (d:uri (first (d:psis (d:instance-of x))))
 				(concatenate 'string arcs "title"))
 		       (= 0 (length (d:themes x)))
+		       (string= (d:charvalue x) "Prometheus")
 		       (string= *xml-string* (d:datatype x))
 		       (= (length (d:psis (d:topic x))) 1)
 		       (string= (d:uri (first (d:psis (d:topic x))))
@@ -1891,6 +1893,7 @@
 		       (string= (d:uri (first (d:psis (d:instance-of x))))
 				(concatenate 'string arcs "title"))
 		       (string= *xml-string* (d:datatype x))
+		       (string= (d:charvalue x) "Der Erlkönig")
 		       (= 1 (length (d:themes x)))
 		       (eql (first (d:themes x)) de)
 		       (= (length (d:psis (d:topic x))) 1)
@@ -1904,6 +1907,7 @@
 		       (string= (d:uri (first (d:psis (d:instance-of x))))
 				(concatenate 'string arcs "content"))
 		       (string= *xml-string* (d:datatype x))
+		       (string= (d:charvalue x) "Hat der alte Hexenmeister ...")
 		       (= 1 (length (d:themes x)))
 		       (eql (first (d:themes x)) de)
 		       (= (length (d:psis (d:topic x))) 1)
@@ -1917,6 +1921,8 @@
 		       (string= (d:uri (first (d:psis (d:instance-of x))))
 				(concatenate 'string arcs "content"))
 		       (string= *xml-string* (d:datatype x))
+		       (string= (d:charvalue x)
+				" Bedecke deinen Himmel, Zeus, ... ")
 		       (= 1 (length (d:themes x)))
 		       (eql (first (d:themes x)) de)
 		       (= (length (d:psis (d:topic x))) 1)
@@ -1930,6 +1936,8 @@
 		       (string= (d:uri (first (d:psis (d:instance-of x))))
 				(concatenate 'string arcs "content"))
 		       (string= *xml-string* (d:datatype x))
+		       (string= (d:charvalue x)
+				"Wer reitet so spät durch Nacht und Wind? ...")
 		       (= 1 (length (d:themes x)))
 		       (eql (first (d:themes x)) de)
 		       (= (length (d:psis (d:topic x))) 1)

Modified: trunk/src/xml/rdf/exporter.lisp
==============================================================================
--- trunk/src/xml/rdf/exporter.lisp	(original)
+++ trunk/src/xml/rdf/exporter.lisp	Mon Aug 24 12:37:40 2009
@@ -4,4 +4,245 @@
 ;;+
 ;;+  Isidorus is freely distributable under the LGPL license.
 ;;+  You can find a detailed description in trunk/docs/LGPL-LICENSE.txt.
-;;+-----------------------------------------------------------------------------
\ No newline at end of file
+;;+-----------------------------------------------------------------------------
+
+(defpackage :rdf-exporter
+  (:use :cl :cxml :elephant :datamodel :isidorus-threading :datamodel)
+  (:import-from :constants
+		*rdf-ns*
+		*rdfs-ns*
+		*xml-ns*
+		*xml-string*
+		*xml-uri*
+		*rdf2tm-ns*
+		*rdf2tm-object*
+		*rdf2tm-subject*
+		*rdf2tm-scope-prefix*
+		*tm2rdf-ns*)
+  (:import-from :isidorus-threading
+		with-reader-lock
+		with-writer-lock)
+  (:import-from :exporter
+		*export-tm*
+		export-to-elem)
+  (:export :export-rdf))
+
+(in-package :rdf-exporter)
+
+
+(defvar *ns-map* nil) ;; ((:prefix <string> :uri <string>))
+
+
+(defun export-rdf (rdf-path &key tm-id (revision (get-revision)))
+  "Exports the topoic map bound to tm-id as RDF."
+  (with-reader-lock
+    (let ((tm (when tm-id
+		(get-item-by-item-identifier tm-id :revision revision))))
+      (setf *ns-map* nil)
+      (setf *export-tm* tm)
+      (with-revision revision
+	(with-open-file (stream rdf-path :direction :output)
+	  (cxml:with-xml-output (cxml:make-character-stream-sink
+				 stream :canonical nil)
+	    (cxml:with-namespace ("isi" *tm2rdf-ns*)
+	      (cxml:with-namespace ("rdf" *rdf-ns*)
+		(cxml:with-namespace ("rdfs" *rdfs-ns*)
+		  (cxml:with-namespace ("xml" *xml-ns*)
+		    (cxml:with-element "rdf:RDF"
+		      (export-to-elem tm #'to-rdf-elem)))))))))))
+  (setf *ns-map* nil))
+
+
+(defun get-ns-prefix (ns-uri)
+  (let ((ns-entry
+	 (find-if #'(lambda(x)
+		      (string= (getf x :uri)
+			       ns-uri))
+		  *ns-map*)))
+    (if ns-entry
+	(getf ns-entry :prefix)
+	(let ((new-name (concatenate
+			 'string "ns"
+			 (write-to-string (+ 1 (length *ns-map*))))))
+	  (push (list :prefix new-name
+		      :uri ns-uri)
+		*ns-map*)
+	  new-name))))
+
+
+(defun separate-uri (uri)
+  (when (or (not uri)
+	    (= (length uri) 0)
+	    (and uri
+		 (> (length uri) 0)
+		 (or (eql (elt uri (- (length uri) 1)) #\#)
+		     (eql (elt uri (- (length uri) 1)) #\/)
+		     (eql (elt uri 0) #\#)
+		     (eql (elt uri 0) #\/))))
+    (error "From separate-uri(): bad ns-uri: ~a" uri))
+  (let ((pos-hash (position #\# uri :from-end t))
+	(pos-slash (position #\/ uri :from-end t)))
+    (unless (or pos-hash pos-slash)
+      (error "From separate-uri(): bad ns-uri: ~a" uri))
+    (if (not (or pos-hash pos-slash))
+	(list :prefix *tm2rdf-ns*
+	      :suffix uri)
+	(let ((prefix (subseq uri 0 (+ (max (or pos-hash 0) (or pos-slash 0)) 1)))
+	      (suffix (subseq uri (+ (max (or pos-hash 0) (or pos-slash 0)) 1))))
+	  (list :prefix prefix
+		:suffix suffix)))))
+
+
+(defun get-xml-lang (topic)
+  (declare (TopicC topic))
+  (when (xml-lang-p topic)
+    (subseq (uri (first (psis topic))) (length *rdf2tm-scope-prefix*))))
+
+
+(defun xml-lang-p (topic)
+  (declare (TopicC topic))
+  (when (= (length (psis topic)) 1)
+    (when (string-starts-with (uri (first (psis topic)))
+			      *rdf2tm-scope-prefix*)
+      t)))
+
+
+(defun make-topic-id (topic)
+  (declare (TopicC topic))
+  (concatenate 'string "id_" (write-to-string (elephant::oid topic))))
+
+
+(defun make-topic-reference (topic)
+  (declare (TopicC topic))
+  (if (psis topic)
+      (cxml:attribute "rdf:resource" (uri (first (psis topic))))
+      (cxml:attribute "rdf:nodeID" (make-topic-id topic))))
+		      
+
+
+(defgeneric to-rdf-elem (construct)
+  (:documentation "Exports Topic Maps Constructs as RDF. "))
+
+
+(defmethod to-rdf-elem ((construct PersistentIdC))
+  (cxml:with-element "isi:subjectIdentifier"
+    (cxml:attribute "rdf:datatype" *xml-uri*)
+    (cxml:text (uri construct))))
+
+
+(defmethod to-rdf-elem ((construct SubjectLocatorC))
+  (cxml:with-element "isi:subjectLocator"
+    (cxml:attribute "rdf:datatype" *xml-uri*)
+    (cxml:text (uri construct))))
+
+
+(defmethod to-rdf-elem ((construct ItemIdentifierC))
+  (cxml:with-element "isi:itemIdentity"
+    (cxml:attribute "rdf:datatype" *xml-uri*)
+    (cxml:text (uri construct))))
+
+
+(defun scopes-to-rdf-elems (owner-construct)
+  (declare ((or AssociationC OccurrenceC NameC VariantC RoleC) owner-construct))
+  (map 'list #'(lambda(x)
+		 (cxml:with-element "isi:scope"
+		   (make-topic-reference x)))
+       (themes owner-construct)))
+
+
+(defun resourceX-to-rdf-elem (owner-construct)
+  (declare ((or OccurrenceC VariantC) owner-construct))
+  (cxml:with-element "isi:value"
+    (cxml:attribute "rdf:datatype" (datatype owner-construct))
+    (cxml:text (charvalue owner-construct))))
+
+
+(defmethod to-rdf-elem ((construct VariantC))
+  (cxml:with-element "isi:variant"
+    (cxml:attribute "rdf:parseType" "Resource")
+    (map 'list #'to-rdf-elem (item-identifiers construct))
+    (scopes-to-rdf-elems construct)
+    (resourceX-to-rdf-elem construct)))
+
+
+(defmethod to-rdf-elem ((construct NameC))
+  (cxml:with-element "isi:name"
+    (cxml:attribute "rdf:parseType" "Resource")
+    (map 'list #'to-rdf-elem (item-identifiers construct))
+    (cxml:with-element "isi:nametype"
+      (make-topic-reference (instance-of construct)))
+    (scopes-to-rdf-elems construct)
+    (cxml:with-element "isi:value"
+      (cxml:attribute "rdf:datatype" *xml-string*)
+      (cxml:text (charvalue construct)))
+    (map 'list #'to-rdf-elem (variants construct))))
+
+
+(defmethod to-rdf-elem ((construct OccurrenceC))
+  (let ((scopes (when (themes construct)
+		  (loop for theme in (themes construct)
+		     when (not (xml-lang-p theme))
+		     collect theme))))
+    (if (or scopes
+	    (item-identifiers construct)
+	    (/= (length (psis (instance-of construct))) 1))
+	(cxml:with-element "isi:occurrence"
+	  (cxml:attribute "rdf:parseType" "Resource")
+	  (map 'list #'to-rdf-elem (item-identifiers construct))
+	  (cxml:with-element "isi:occurrencetype"
+	    (make-topic-reference (instance-of construct)))
+	  (scopes-to-rdf-elems construct)
+	  (resourceX-to-rdf-elem construct))
+	(let ((ns-list
+	       (separate-uri (uri (first (psis (instance-of construct)))))))
+	  (let ((ns (getf ns-list :prefix))
+		(tag-name (getf ns-list :suffix)))
+	    (cxml:with-namespace ((get-ns-prefix ns) ns)
+	      (cxml:with-element (concatenate 'string (get-ns-prefix ns)
+					      ":" tag-name)
+		(cxml:attribute "rdf:datatype" (datatype construct))
+		(when (themes construct)
+		  (cxml:attribute "xml:lang" (get-xml-lang
+					      (first (themes construct)))))
+		(cxml:text (charvalue construct)))))))))
+
+
+(defmethod to-rdf-elem ((construct TopicC))
+  ;TODO: what's with used-as-player and core-topics
+  (format t "--> ~a " (if (psis construct)
+			  (uri (first (psis construct)))
+			  (make-topic-id construct)))
+  (if (and (not (or (> (length (psis construct)) 1)
+		    (item-identifiers construct)
+		    (locators construct)
+		    (names construct)
+		    (occurrences construct)))
+	   (or (used-as-type construct)
+	       (used-as-theme construct)))
+      nil ;; do not export this topic explicitly, since it is exported as
+          ;; rdf:resource, rdf:about or any other reference
+      (cxml:with-element "rdf:Description"
+	(let ((psi (when (psis construct)
+		     (first (psis construct)))))
+	  (if psi
+	      (cxml:attribute "rdf:about" (uri psi))
+	      (cxml:attribute "rdf:nodeID" (make-topic-id construct)))
+	  (map 'list #'to-rdf-elem (remove psi (psis construct)))
+	  (map 'list #'to-rdf-elem (locators construct))
+	  (map 'list #'to-rdf-elem (item-identifiers construct))
+	  (map 'list #'(lambda(x)
+			 (cxml:with-element "rdf:type"
+			   (make-topic-reference x)))
+	       (list-instanceOf construct))
+	  (map 'list #'(lambda(x)
+			 (cxml:with-element "rdfs:subClassOf"
+			   (make-topic-reference x)))
+	       (list-super-types construct))
+	  (map 'list #'to-rdf-elem (names construct))
+	  (map 'list #'to-rdf-elem (occurrences construct)))))
+  (format t "<--~%"))
+  
+
+(defmethod to-rdf-elem ((construct AssociationC))
+  ;TODO: check if the association has to be exported or not
+  )
\ No newline at end of file

Modified: trunk/src/xml/rdf/importer.lisp
==============================================================================
--- trunk/src/xml/rdf/importer.lisp	(original)
+++ trunk/src/xml/rdf/importer.lisp	Mon Aug 24 12:37:40 2009
@@ -589,7 +589,7 @@
 (defun get-literals-of-node-content (node tm-id xml-base xml-lang)
   "Returns a list of literals that is produced of a node's content."
   (declare (dom:element node))
-  (tm-id-p tm-id "get-literals-of-content")
+  (tm-id-p tm-id "get-literals-of-noode-content")
   (let ((properties (child-nodes-or-text node :trim t))
 	(fn-xml-base (get-xml-base node :old-base xml-base))
 	(fn-xml-lang (get-xml-lang node :old-lang xml-lang)))
@@ -607,7 +607,8 @@
 					   property nil))
 			   (prop-content (child-nodes-or-text property)))
 		       (and (or datatype
-				(string= parseType "Literal")
+				(and parseType
+				     (string= parseType "Literal"))
 				(and (not (or nodeID resource UUID parseType))
 				     (or (not prop-content)
 					 (stringp prop-content))))

Modified: trunk/src/xml/rdf/rdf_core_psis.xtm
==============================================================================
--- trunk/src/xml/rdf/rdf_core_psis.xtm	(original)
+++ trunk/src/xml/rdf/rdf_core_psis.xtm	Mon Aug 24 12:37:40 2009
@@ -11,14 +11,14 @@
 <topicMap xmlns="http://www.topicmaps.org/xtm/" version="2.0">
 
   <topic id="subject">
-    <subjectIdentifier href="http://isidorus/rdf2tm_mapping#subject"/>
+    <subjectIdentifier href="http://isidorus/rdf2tm_mapping/subject"/>
     <name>
       <value>subject</value>
     </name>
   </topic>
 
   <topic id="object">
-    <subjectIdentifier href="http://isidorus/rdf2tm_mapping#object"/>
+    <subjectIdentifier href="http://isidorus/rdf2tm_mapping/object"/>
     <name>
       <value>object</value>
     </name>

Modified: trunk/src/xml/rdf/rdf_tools.lisp
==============================================================================
--- trunk/src/xml/rdf/rdf_tools.lisp	(original)
+++ trunk/src/xml/rdf/rdf_tools.lisp	Mon Aug 24 12:37:40 2009
@@ -33,8 +33,7 @@
 		*rdf-rest*
 		*rdf2tm-scope-prefix*)
   (:import-from :xml-constants
-		*rdf_core_psis.xtm*)
-  (:import-from :xml-constants
+		*rdf_core_psis.xtm*
 		*core_psis.xtm*)
   (:import-from :xml-tools
                 get-attribute
@@ -306,7 +305,6 @@
     (when (and (string= property-ns *rdf-ns*)
 	       (string= property-name "li"))
       (set-_n-name owner-identifier property)))
-      ;(set-_n-name property _n-counter)))
   t)
 
 
@@ -371,6 +369,7 @@
 	     datatype))
     (when (and (or nodeID resource)
 	       (> (length content) 0))
+      ;(set-_n-name property _n-counter)))
       (error "~awhen ~a is set no content is allowed: ~a!"
 	     err-pref
 	     (cond
@@ -428,7 +427,6 @@
    function and sets all rdf:li properties as a tupple to the
    *_n-map* list."
   (let ((child-nodes (child-nodes-or-text node :trim t)))
-	;(_n-counter 0))
     (when (get-ns-attribute node "li")
       (dom:map-node-map
        #'(lambda(attr)




More information about the Isidorus-cvs mailing list