Index: CMDI-Interoperability/CMD2RDF/trunk/build.xml
===================================================================
--- CMDI-Interoperability/CMD2RDF/trunk/build.xml	(revision 5244)
+++ CMDI-Interoperability/CMD2RDF/trunk/build.xml	(revision 5245)
@@ -60,10 +60,10 @@
 	<target name="profiles2rdf" description="transform CMDcomponents from source dir to RDF">
 		<!--		basedir="${in.dir}" includes="**/oai_meertens_knaw_nl_http___hdl_handle_net_10744_mi_022000e4_0cc1_4699_849c_4b41a01d4f01.xml" destdir="${out.dir}" extension=".rdf"-->
-		<saxon-xslt style="xsl/Component2RDF.xsl" 
+		<saxon-xslt style="xsl/Component2RDFcache.xsl" 
 			basedir="${in.dir}" includes="*.xml" destdir="${out.dir}" extension=".rdf"
-			force="true" reloadstylesheet="false" >
-			<param name="base_strip" expression="${base.strip}"/>
-			<param name="base_add" expression="${base.add}"/>
-			<param name="cache_dir" expression="${cache.dir}"/>
+			force="true"  reloadstylesheet="true">
+			<!--<param name="base_strip" expression="${base.strip}"/>
+			<param name="base_add" expression="${base.add}"/>-->
+			<param name="out" expression="${out.dir}"/>
 			<!--			<param name="cache" expression="refresh"/>-->
 		</saxon-xslt>
Index: CMDI-Interoperability/CMD2RDF/trunk/xsl/Component2RDFcache.xsl
===================================================================
--- CMDI-Interoperability/CMD2RDF/trunk/xsl/Component2RDFcache.xsl	(revision 5245)
+++ CMDI-Interoperability/CMD2RDF/trunk/xsl/Component2RDFcache.xsl	(revision 5245)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE rdf:RDF [
+    <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
+    <!ENTITY rdfs 'http://www.w3.org/TR/WD-rdf-schema#'>
+    <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>
+    <!ENTITY cmdm 'http://www.clarin.eu/cmd/general.rdf#'>
+]>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:dcr="http://www.isocat.org/ns/dcr.rdf#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:cmd="http://www.clarin.eu/cmd/" xmlns:cmdm="http://www.clarin.eu/cmd/general.rdf" xmlns:dcterms="http://purl.org/dc/terms/"
+    xmlns:my="myFunctions" >
+
+<xsl:import href="Component2RDF.xsl"/>
+    
+    <xsl:output method="xml" encoding="UTF-8"/>
+
+    <xsl:param name="out" select="'.'"/>
+    
+    <xsl:include href="CMD2RDFcache.xsl"/>
+
+    <xsl:function name="my:outPath">
+        <xsl:param name="key" />		
+        <xsl:param name="id" />
+        
+        <!--    resolve-uri($out,$base-uri) -->
+        <xsl:value-of select="concat(resolve-uri($out), if (ends-with($out,'/') or ends-with($out,'\')) then '' else '/',
+            $key, if ($id!='') then concat('/', my:normalize($id)) else '', '.rdf')" />		
+    </xsl:function>
+    
+    
+    <!-- let's create some RDF -->
+    <xsl:template match="/CMD_ComponentSpec">
+        <!-- for the output base replace the xml extension by rdf -->
+        <xsl:message>writing <xsl:value-of select="my:outPath('profiles',Header/ID)" /></xsl:message>
+        <xsl:result-document href="{my:outPath('profiles',Header/ID)}">
+            <rdf:RDF xml:base="{if (@isProfile='true') then (cmd:ppath(Header/ID,'rdf')) else (cmd:cpath(Header/ID,'rdf'))}">
+                <xsl:apply-templates>
+                    <xsl:with-param name="context" tunnel="yes" select="''"/>
+                </xsl:apply-templates>
+            </rdf:RDF>
+        </xsl:result-document>
+    </xsl:template>
+
+    <!-- a profile (and component?) contains all the nested components as well,
+         but as these are shared we want to also share their RDF representations.
+         So restart the traversal when there is reuse. -->
+    <xsl:template match="CMD_Component[exists(@ComponentId)]">
+        <xsl:variable name="out-path" select="my:outPath('component',@ComponentId)" />
+        <xsl:if test="empty(preceding::CMD_Component[@ComponentId=current()/@ComponentId])
+            and not(doc-available($out-path))">
+            <xsl:result-document href="{$out-path}">
+                <!-- for the output base replace the xml extension by rdf -->
+                <rdf:RDF xml:base="{cmd:cpath(@ComponentId,'rdf')}">
+                    <xsl:call-template name="CMD_Component">
+                        <xsl:with-param name="context" tunnel="yes" select="''"/>
+                    </xsl:call-template>
+                </rdf:RDF>
+            </xsl:result-document>
+        </xsl:if>
+    </xsl:template>
+
+</xsl:stylesheet>
