source: SMC/trunk/SMC/src/scripts/dcr_smc2skos.xsl @ 2235

Last change on this file since 2235 was 2235, checked in by vronk, 12 years ago

intermediate commit of older minor(?) changes

File size: 7.3 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet
3  version="2.0"
4  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5  xmlns:xs="http://www.w3.org/2001/XMLSchema"
6  xmlns:my="myFunctions"
7  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8  xmlns:openskos="http://openskos.org/xmlns#"
9  xmlns:skos="http://www.w3.org/2004/02/skos/core#"
10  xmlns:dc="http://purl.org/dc/elements/1.1/"
11 
12        xmlns:dcif="http://www.isocat.org/ns/dcif"
13        exclude-result-prefixes="xs my"
14        >
15<xsl:import href="smc_commons.xsl"/>
16       
17        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet">
18                <xd:desc>
19                        <xd:p>generate a SKOS-version for a datcat-profile mapping from internal format (Termset/Concept/Term)</xd:p>
20                        <xd:p>also expects data from relationregistry in the variable: <xd:ref name="rr-relations"></xd:ref></xd:p>                     
21                        <xd:p><xd:b>Created on:</xd:b> Sep 18, 2012</xd:p>
22                        <xd:p><xd:b>Author:</xd:b> m</xd:p>
23                        <xd:p></xd:p>
24                </xd:desc>
25        </xd:doc>
26
27
28
29        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
30                <xd:desc>
31                        <xd:p></xd:p>
32                </xd:desc>
33        </xd:doc>
34<xsl:output method="xml" indent="yes" > </xsl:output>
35
36
37        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
38                <xd:desc>
39                        <xd:p>Which Termset shall be processed</xd:p> 
40                        <xd:p>Input file contains multiple Termsets (in /Termsets/Termset), but we want each termset in a separate collection</xd:p>
41                </xd:desc>
42        </xd:doc>
43<xsl:param name="set" select="'isocat'"></xsl:param>
44
45<!--<xsl:template name="continue-root">
46<xsl:message>count terms:<xsl:value-of select="count(/dcif:dataCategorySelection/dcif:dataCategory)" /></xsl:message>
47        <xsl:apply-templates select="/dcif:dataCategorySelection" />
48</xsl:template>
49-->
50        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
51                <xd:desc>
52                        <xd:p></xd:p>
53                </xd:desc>
54        </xd:doc>
55        <xsl:template match="/" >
56               
57                <xsl:apply-templates select="/Termsets/Termset[@set=$set]"></xsl:apply-templates>               
58        </xsl:template>
59               
60        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
61                <xd:desc>
62                        <xd:p></xd:p>
63                </xd:desc>
64        </xd:doc>
65<xsl:template match="Termset" > 
66        <rdf:RDF 
67                openskos:tenant="icltt" openskos:collection="{@set}" openskos:key="icltt2012">
68                <rdf:Description rdf:about="{@url}">
69                        <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#ConceptScheme"/>
70                        <dc:title xml:lang="en"><xsl:value-of select="@name"></xsl:value-of></dc:title>
71                        <dc:creator xml:lang="en">ICLTT</dc:creator>                   
72                        <dc:description xml:lang="en">Data Categories</dc:description>                 
73                        <xsl:apply-templates mode="index"/>
74                </rdf:Description>             
75                <xsl:apply-templates >
76                        <xsl:with-param name="scheme" select="@url"></xsl:with-param>
77                </xsl:apply-templates>         
78        </rdf:RDF>     
79</xsl:template> 
80
81        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
82                <xd:desc>
83                        <xd:p></xd:p>
84                </xd:desc>
85        </xd:doc>
86<xsl:template match="Concept" mode="index">
87        <skos:hasTopConcept rdf:resource="{@id}"/>
88</xsl:template>
89       
90       
91        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
92                <xd:desc>
93                        <xd:p></xd:p>
94                </xd:desc>
95                <xd:param name="scheme"></xd:param>
96        </xd:doc>
97<xsl:template match="Concept" >
98        <xsl:param name="scheme" />
99        <rdf:Description rdf:about="{@id}">
100                <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
101                <skos:inScheme rdf:resource="{$scheme}"/>
102                <xsl:apply-templates select="Term|info"></xsl:apply-templates>
103               
104                <xsl:call-template name="matches" >
105                        <xsl:with-param name="concept" select="@id"></xsl:with-param>
106                </xsl:call-template>           
107        </rdf:Description>
108</xsl:template>
109
110
111        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
112                <xd:desc>
113                        <xd:p></xd:p>
114                </xd:desc>
115        </xd:doc>
116        <xsl:template match="info" >
117                <skos:definition xml:lang="{@xml:lang}"><xsl:value-of select="."/></skos:definition>
118        </xsl:template>
119       
120       
121        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
122                <xd:desc>
123                        <xd:p></xd:p>
124                </xd:desc>
125        </xd:doc>
126        <xsl:template match="Term" >
127       
128        <xsl:choose>           
129                <!-- in isocat mnemonic is taken as default,  in dublincore there is only one Term (this is not too reliable)                   -->
130                <xsl:when test="count(../Term)=1" >
131                        <skos:prefLabel xml:lang="en"><xsl:value-of select="."/></skos:prefLabel>       
132                </xsl:when>
133                <xsl:when test="@type='mnemonic'" >
134                        <skos:altLabel xml:lang="en"><xsl:value-of select="."/></skos:altLabel> 
135                </xsl:when>     
136                <xsl:when test="@type='label'">
137                        <skos:prefLabel xml:lang="{@xml:lang}"><xsl:value-of select="."/></skos:prefLabel>
138                </xsl:when>
139                <xsl:when test="@type='id'" >
140                        <skos:altLabel ><xsl:value-of select="."/></skos:altLabel>
141                </xsl:when>                             
142                <xsl:otherwise>
143                        <skos:altLabel ><xsl:value-of select="."/></skos:altLabel>
144                </xsl:otherwise>
145        </xsl:choose>
146       
147               
148        <!--
149        <xsl:variable name="n" >
150                <xsl:choose>
151                        <xsl:when test=".//dcif:name[@xml:lang=$lang]">
152                                <xsl:value-of select=".//dcif:name[@xml:lang=$lang]" />
153                        </xsl:when>
154                        <xsl:when test=".//dcif:name[@xml:lang=$default_lang]">
155                                <xsl:value-of select=".//dcif:name[@xml:lang=$default_lang]" />
156                        </xsl:when>
157                        <xsl:when test=".//dcif:name">
158                                <xsl:value-of select=".//dcif:name" />
159                        </xsl:when>
160                        <xsl:when test=".//dcif:dataElementName">
161                                <xsl:value-of select=".//dcif:dataElementName" />
162                        </xsl:when>
163                        <xsl:otherwise>
164                                <xsl:value-of select=".//dcif:identifier" />
165                        </xsl:otherwise>
166                </xsl:choose>
167        </xsl:variable>
168       
169        <!-\-  <xsl:variable name="datcat" select="my:shortURL(@pid)" />  -\->
170                               
171        <Term type="datcat" name="{$n}" datcat="{@pid}" id="{.//dcif:identifier}">
172                <xsl:copy-of select="dcif:administrationRecord/*" />
173                <xsl:choose>
174                <xsl:when test=".//dcif:languageSection[language=$lang]" >
175                        <xsl:for-each select=".//dcif:languageSection[language=$lang]//*[@xml:lang=$lang]" >                   
176                                        <xsl:element name="{name()}" ><xsl:value-of select="." /></xsl:element>                 
177                        </xsl:for-each>                 
178                </xsl:when>
179                <xsl:otherwise>
180                        <xsl:for-each select=".//dcif:languageSection[1]//*[exists(text()) and text()!='']" >                   
181                                        <xsl:element name="{name()}" ><xsl:value-of select="." /></xsl:element>                 
182                        </xsl:for-each>
183                </xsl:otherwise>
184                </xsl:choose>
185                                               
186                <!-\-   probably need to add conceptual domain! -\->
187        </Term>-->
188</xsl:template>
189
190        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
191                <xd:desc>
192                        <xd:p></xd:p>
193                </xd:desc>
194                <xd:param name="concept"></xd:param>
195        </xd:doc>
196<xsl:template name="matches">
197        <xsl:param name="concept"></xsl:param>
198<!--<DEBUG><xsl:value-of select="$concept"></xsl:value-of></DEBUG>      -->
199        <xsl:for-each select="$rr-relations//Relation[Concept/@id=$concept]" >
200                <xsl:variable name="other_concept" select="Concept[not(@id=$concept)]"></xsl:variable>
201                <xsl:choose>
202                        <xsl:when test="@type='sameAs'">
203                                <skos:exactMatch rdf:resource="{$other_concept/@id}" />
204                        </xsl:when>
205                        <xsl:when test="@type='subClassOf' and $other_concept/@role='about'">
206                                <skos:narrowMatch rdf:resource="{$other_concept/@id}" />       
207                        </xsl:when>
208                        <xsl:when test="@type='subClassOf' and not($other_concept/@role='about')">
209                                <skos:broadMatch rdf:resource="{$other_concept/@id}" /> 
210                        </xsl:when>
211                        <xsl:otherwise>
212                                <skos:relatedMatch rdf:resource="{$other_concept/@id}" />
213                        </xsl:otherwise>
214                               
215                </xsl:choose>
216               
217               
218        </xsl:for-each>
219       
220       
221</xsl:template>
222
223</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.