summaryrefslogtreecommitdiff
path: root/utils/ontology/rdfxml2metadatasample.xsl
blob: d4d3e8317d14e252ca683f925f1a74e48391fad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  xmlns:nid3="http://tracker.api.gnome.org/ontology/v3/nid3#"
  xmlns:nfo="http://tracker.api.gnome.org/ontology/v3/nfo#"
  xmlns:nmo="http://tracker.api.gnome.org/ontology/v3/nmo#"
  xmlns:nie="http://tracker.api.gnome.org/ontology/v3/nie#"
  xmlns:exif="http://www.kanzaki.com/ns/exif#"
  xmlns:nao="http://tracker.api.gnome.org/ontology/v3/nao#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:protege="http://protege.stanford.edu/system#"
  xmlns:dcterms="http://purl.org/dc/terms/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:ncal="http://tracker.api.gnome.org/ontology/v3/ncal#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
  xmlns:nrl="http://tracker.api.gnome.org/ontology/v3/nrl#"
  xmlns:pimo="http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#"
  xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
  xmlns:tmo="http://www.semanticdesktop.org/ontologies/2008/05/20/tmo#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:nco="http://tracker.api.gnome.org/ontology/v3/nco#"
  xmlns:nexif="http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#">

<xsl:output method="text" />

<xsl:template name="predicate-of">
 <xsl:param name="about"/>
 <xsl:choose>
  <xsl:when test="substring-after($about, '/')">
   <xsl:call-template name="predicate-of">
     <xsl:with-param name="about" select="substring-after($about, '/')"/>
   </xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
     <xsl:choose>
       <xsl:when test="substring-after($about, '#')">
         <xsl:if test="substring-before($about, '#') != 'XMLSchema'"><xsl:value-of select="substring-before($about, '#')"/>:</xsl:if><xsl:value-of select="substring-after($about, '#')"/>
       </xsl:when>
       <xsl:otherwise>dc:<xsl:value-of select="$about"/></xsl:otherwise>
    </xsl:choose>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template name="convert-datatype-of">
 <xsl:param name="datatype"/>
 <xsl:choose>
  <xsl:when test="substring-after($datatype, ':')">resource</xsl:when>
  <xsl:when test="$datatype = 'float'">double</xsl:when>
  <xsl:when test="$datatype = 'dateTime'">date</xsl:when>
  <xsl:otherwise><xsl:value-of select="$datatype"/></xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="rdf:RDF">
<xsl:for-each select="rdf:Property">

[<xsl:call-template name="predicate-of"><xsl:with-param name="about"><xsl:value-of select="@rdf:about"/></xsl:with-param></xsl:call-template>]<xsl:choose>
<xsl:when test="rdfs:range">
DataType=<xsl:call-template name="convert-datatype-of"><xsl:with-param name="datatype">
<xsl:call-template name="predicate-of"><xsl:with-param name="about"><xsl:value-of select="rdfs:range/@rdf:resource"/></xsl:with-param></xsl:call-template></xsl:with-param></xsl:call-template>
</xsl:when>
<xsl:otherwise>Abstract=true
DataType=string</xsl:otherwise>
</xsl:choose>
<xsl:if test="rdfs:label">
DisplayName=<xsl:value-of select="rdfs:label"/>
</xsl:if>

<xsl:if test="rdfs:domain">
Domain=<xsl:call-template name="predicate-of"><xsl:with-param name="about"><xsl:value-of select="rdfs:domain/@rdf:resource"/></xsl:with-param></xsl:call-template></xsl:if>

<xsl:if test="rdfs:subPropertyOf">
SuperProperties=<xsl:for-each select="rdfs:subPropertyOf">
<xsl:if test="@rdf:resource"><xsl:call-template name="predicate-of"><xsl:with-param name="about"><xsl:value-of select="@rdf:resource"/></xsl:with-param></xsl:call-template>;</xsl:if><xsl:for-each select="rdf:Property"><xsl:call-template name="predicate-of"><xsl:with-param name="about"><xsl:value-of select="@rdf:about"/></xsl:with-param></xsl:call-template>;</xsl:for-each></xsl:for-each></xsl:if>
<xsl:if test="rdfs:comment">
Description=<xsl:value-of select="rdfs:comment"/></xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>