account example from dm
authorTim L <lebot@rpi.edu>
Tue, 03 Jan 2012 15:55:23 -0500
changeset 1317 898c71190fd5
parent 1316 6616e52c3e4d
child 1318 5f7b67f0a7ed
account example from dm
model/scrape/used/src/scrape-dm.xsl
ontology/components/Account/prov-dm-b984f67f3465-example.ttl
--- a/model/scrape/used/src/scrape-dm.xsl	Tue Jan 03 16:35:40 2012 +0000
+++ b/model/scrape/used/src/scrape-dm.xsl	Tue Jan 03 15:55:23 2012 -0500
@@ -4,6 +4,9 @@
                xmlns:x="http://www.w3.org/1999/xhtml">
 <xsl:output method="text"/>
 
+<xsl:param name="view"/> <!-- An identifier of the view of http://www.w3.org/TR/prov-dm/ (use a message digest like md5) -->
+<xsl:param name="dirbase" select="'generated/'"/>
+
 <xsl:template match="/">
    <xsl:apply-templates select="//*[@class='codeexample']"/>
 </xsl:template>
@@ -22,17 +25,49 @@
       </xsl:for-each>
    </xsl:variable>
 
-   <xsl:variable name="filename" select="concat('generated/codeexamples/eg-',
+   <xsl:variable name="directory" select="concat($dirbase,'codeexamples/')"/>
+   <xsl:variable name="filename" select="concat('eg-',
                                                 if (position() le 9) then '0' else '',position(),'-',
                                                 $section/number,'-',
-                                                replace(lower-case($section/title),' ','-'),
-                                                '.txt')"/>
-   <xsl:value-of select="concat(position(),' ',local-name(.),' ',@class,' ',$section/number,' ',$section/title,$NL,'--',$NL)"/>
-   <xsl:apply-templates select="." mode="text"/>
-   <xsl:result-document href="{$filename}">
+                                                replace(lower-case($section/title),' ','-'))"/>
+   <xsl:value-of select="concat(position(),' ',local-name(.),' ',@class,' ',$section/number,' ',$section/title,$NL)"/>
+
+   <xsl:result-document href="{concat($directory,$filename,'.txt')}">
       <xsl:apply-templates select="." mode="text"/>
    </xsl:result-document>
-   <xsl:value-of select="concat('--',$NL,$NL)"/>
+
+   <xsl:variable name="section-uriref" select="concat('&lt;',$view,'/',$section/number,'>')"/>
+   <xsl:variable name="view-uriref"    select="concat('&lt;',$view,'>')"/>
+   <xsl:result-document href="{$directory}{$filename}.ttl">
+      <xsl:value-of select="concat($prefixes,
+                                   ':example_',position(),$NL,
+                                   '   a :PROV-DM-Example, prov:Quote;',$NL,
+                                   '   dcterms:identifier ',position(),';',$NL,
+                                   '   prov:wasQuotedFrom ',$section-uriref,';',$NL,
+                                   '   rdf:value ',$TQ)"/>
+      <xsl:apply-templates select="." mode="text"/>
+      <xsl:value-of select="concat($TQ,';',$NL,
+                                   '   dcterms:date ',$DQ,current-dateTime(),$DQ,'^^xsd:dateTime;',$NL,
+                                   '   a frbr:Manifestation;',$NL,
+                                   '   frbr:exemplar [',$NL,
+                                   '      a frbr:Item;',$NL,
+                                   '      nfo:fileName     ',$DQ,$filename,'.txt',$DQ,'^^xsd:string;',$NL,
+                                   '      nfo:fileUrl      &lt;',$filename,'.txt>;',$NL,
+                                   '      nfo:fileCreated ',$DQ,current-dateTime(),$DQ,'^^xsd:dateTime;',$NL,
+                                   '   ];',$NL,
+                                   '.',$NL,$NL,
+                                   $section-uriref,$NL,
+                                   '   a doco:Section;',$NL,
+                                   '   dcterms:identifier ',$DQ,$section/number,$DQ,';',$NL,
+                                   '   dcterms:title      ',$DQ,$section/title,$DQ,';',$NL,
+                                   '   dcterms:isPartOf   ',$view-uriref,';',$NL,
+                                   '.',$NL,$NL,
+                                   $view-uriref,$NL,
+                                   '   prov:viewOf         &lt;http://www.w3.org/TR/prov-dm/>;',$NL,
+                                   '   dcterms:identifier ',$DQ,$view,$DQ,';',$NL,
+                                   '.',$NL
+                                   )"/>
+   </xsl:result-document>
 </xsl:template>
 
 <xsl:template match="@*|node()" mode="text">
@@ -42,9 +77,28 @@
   </xsl:copy>
 </xsl:template>
 
-<xsl:variable name="NL">
+<xsl:variable name="NL"> <!-- newline -->
 <xsl:text>
 </xsl:text>
 </xsl:variable>
 
+<xsl:variable name="DQ"> <!-- double quote -->
+<xsl:text>"</xsl:text>
+</xsl:variable>
+
+<xsl:variable name="TQ"> <!-- triple quote -->
+<xsl:text>"""</xsl:text>
+</xsl:variable>
+
+<xsl:variable name="prefixes"><![CDATA[@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+@prefix dcterms: <http://purl.org/dc/terms/> .
+@prefix frbr:    <http://purl.org/vocab/frbr/core#> .
+@prefix nfo:     <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
+@prefix doco:    <http://purl.org/spar/doco/> .
+@prefix prov:    <http://www.w3.org/ns/prov-o/> .
+@prefix :        <#> .
+
+]]></xsl:variable>
 </xsl:transform>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ontology/components/Account/prov-dm-b984f67f3465-example.ttl	Tue Jan 03 15:55:23 2012 -0500
@@ -0,0 +1,37 @@
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+@prefix owl:     <http://www.w3.org/2002/07/owl#> .
+@prefix time:    <http://www.w3.org/2006/time#> .
+@prefix dcterms: <http://purl.org/dc/terms/> .
+@prefix skos:    <http://www.w3.org/2008/05/skos#> .
+@prefix prov:    <http://www.w3.org/ns/prov-o/> .
+@prefix :        <#> .
+
+:e0
+   dcterms:description "entity(e0, [ prov:type='File', ex:path='/shared/crime.txt', ex:creator='Alice' ])";
+   a prov:Entity;
+   a :File;
+   ex:path "/shared/crime.txt";
+   ex:creator :Alice;
+.
+
+:e2
+   dcterms:description "wasDerivedFrom(e2,e1)";
+   prov:wasDerivedFrom :e1;
+.
+
+:a0
+   dcterms:description "activity(a0,t,,[prov:type='createFile'])";
+   a prov:Activity;
+   a :CreateFile;
+.
+
+:e0
+   dcterms:description "wasGeneratedBy(e0,a0)";
+   prov:wasGeneratedBy :a0;
+.
+
+:a4
+   dcterms:description "wasAssociatedWith(a4, ag5, [prov:role='communicator'])";
+.