--- 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('<',$view,'/',$section/number,'>')"/>
+ <xsl:variable name="view-uriref" select="concat('<',$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 <',$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 <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>