Changeset 6497 for cats


Ignore:
Timestamp:
09/16/15 12:22:18 (9 years ago)
Author:
Menzo Windhouwer
Message:

M openskos.xsl

  • aligned with the current OpenSKOS RDF serialization
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cats/ISOcat/trunk/mod-ISOcat-interface-rest/representations/dcs2/openskos.xsl

    r5898 r6497  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<!--
    3   Copyright 2013 The Language Archive, Max Planck Institute for Psycholinguistics (MPIP)
     3  Copyright 2013-2015 The Language Archive, Max Planck Institute for Psycholinguistics (MPIP)
    44
    55  This code is part of ISOcat (www.isocat.org).
     
    2222    <xsl:param name="props"/>
    2323        <xsl:param name="approve" select="('CLARIN-NL/VL','Athens Core')"/>
     24        <xsl:param name="do-uniq-notation" select="false()"/>
    2425        <xsl:variable name="doc" select="/"/>
    2526    <xsl:template match="text()"/>
     
    2930                <xsl:attribute name="xml:base" select="concat($base,'#')"/>
    3031            </xsl:if>
    31                 <openskos:skosCollection rdf:about="tmp:S-{replace(@owner,'\s','')}-{replace(@name,'\s','')}">
     32                <rdf:Description rdf:about="tmp:S-{replace(@owner,'\s','')}-{replace(@name,'\s','')}">
     33                    <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Collection"/>
    3234                        <dc:title>
    3335                                <xsl:value-of select="@name"/>
     
    3638                                <skos:member rdf:resource="tmp:C-{substring-after(@pid,'DC-')}"/>
    3739                        </xsl:for-each>
    38                 </openskos:skosCollection>
     40                </rdf:Description>
    3941            <xsl:for-each select="distinct-values(//dcif:profile)">
    4042                <xsl:variable name="prof" select="."/>
    41                 <skos:ConceptScheme rdf:about="tmp:P-{replace(.,'\s','')}">
     43                <rdf:Description rdf:about="tmp:P-{replace(.,'\s','')}">
     44                    <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#ConceptScheme"/>
    4245                    <dc:title>
    4346                        <xsl:value-of select="."/>
     
    4649                                <skos:hasTopConcept rdf:resource="tmp:C-{substring-after(@pid,'DC-')}"/>
    4750                        </xsl:for-each>
    48                 </skos:ConceptScheme>
     51                </rdf:Description>
    4952            </xsl:for-each>
    5053            <xsl:apply-templates/>
     
    5255    </xsl:template>
    5356    <xsl:template match="dcif:dataCategory">
     57        <xsl:variable name="dc" select="."/>
     58        <xsl:variable name="key" select="substring-after(@pid,'DC-')"/>
    5459        <xsl:variable name="name" select="@isocat:name"/>
    5560        <xsl:variable name="concept">
    56                 <skos:Concept rdf:about="tmp:C-{substring-after(@pid,'DC-')}">
     61                <rdf:Description rdf:about="tmp:C-{$key}">
     62                    <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Collection"/>
    5763                        <!-- link back to the collection -->
    5864                        <xsl:for-each select="ancestor::dcif:dataCategorySelection">
     
    9399                <!-- xsl:for-each to change context, but there will be only one Administration Record -->
    94100                <xsl:for-each select="dcif:administrationInformationSection/dcif:administrationRecord">
     101                        <xsl:variable name="id" select="dcif:identifier"/>
    95102                    <skos:notation>
    96                         <xsl:value-of select="dcif:identifier"/>
     103                        <xsl:value-of select="$id"/>
     104                        <xsl:if test="$do-uniq-notation">
     105                                <xsl:if test="exists($dc/preceding-sibling::dcif:dataCategory[dcif:administrationInformationSection/dcif:administrationRecord/dcif:identifier=$id])">
     106                                        <xsl:text>-</xsl:text>
     107                                        <xsl:value-of select="$key"/>
     108                                </xsl:if>
     109                        </xsl:if>
    97110                    </skos:notation>
     111                        <skos:altLabel>
     112                                <xsl:value-of select="$id"/>
     113                        </skos:altLabel>
    98114                </xsl:for-each>
    99115
     
    111127                    <xsl:for-each-group select="dcif:dataElementNameSection" group-by="dcif:dataElementName">
    112128                        <xsl:if test="normalize-space(current-grouping-key())!=''">
    113                             <skos:notation>
     129                                <skos:altLabel>
    114130                                <xsl:value-of select="normalize-space(current-grouping-key())"/>
    115                             </skos:notation>
     131                            </skos:altLabel>
    116132                        </xsl:if>
    117133                    </xsl:for-each-group>
     
    129145                    -->
    130146
    131                     <xsl:for-each select="dcif:languageSection[dcif:language='en']">
     147                        <skos:prefLabel xml:lang="en">
     148                                <xsl:choose>
     149                                        <xsl:when test="normalize-space($name)=''">
     150                                                <xsl:value-of select="normalize-space(ancestor::dcif:dataCategory/dcif:administrationInformationSection/dcif:administrationRecord/dcif:identifier)"/>
     151                                        </xsl:when>
     152                                        <xsl:otherwise>
     153                                                <xsl:value-of select="normalize-space($name)"/>
     154                                        </xsl:otherwise>
     155                                </xsl:choose>
     156                        </skos:prefLabel>
     157
     158                        <xsl:for-each select="dcif:languageSection[dcif:language='en']">
    132159                        <xsl:variable name="lang" select="dcif:language"/>
    133 
    134                         <xsl:if test="$lang='en'">
    135                             <skos:prefLabel xml:lang="{$lang}">
    136                                 <xsl:value-of select="normalize-space($name)"/>
    137                             </skos:prefLabel>
    138                         </xsl:if>
    139160
    140161                        <xsl:for-each-group select="dcif:nameSection[not($lang='en' and dcif:name=$name)]" group-by="dcif:nameStatus">
     
    228249                -->
    229250
    230             </skos:Concept>
     251            </rdf:Description>
    231252        </xsl:variable>
    232253        <xsl:apply-templates select="$concept" mode="cleanup"/>
     
    265286        </xsl:if>
    266287    </xsl:template>
     288        <xsl:template match="skos:Concept[normalize-space(skos:prefLabel)='']" mode="cleanup">
     289                <xsl:copy>
     290                        <xsl:apply-templates select="@*" mode="#current"/>
     291                        <skos:prefLabel xml:lang="en">
     292                                <xsl:value-of select="skos:notation"/>
     293                        </skos:prefLabel>
     294                        <xsl:apply-templates select="node() except skos:prefLabel" mode="#current"/>
     295                </xsl:copy>
     296        </xsl:template>
    267297</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.