Changeset 5310 for CMDI-Interoperability


Ignore:
Timestamp:
05/29/14 13:10:47 (10 years ago)
Author:
Menzo Windhouwer
Message:

M xsl/CMDRecord2RDF.xsl
M xsl/CMD2RDF.xsl
M xsl/CMDRecord2RDFcache.xsl
M xsl/CMD2RDFcache.xsl

  • be a bit smarter in finding and cleaning the profile ID
Location:
CMDI-Interoperability/CMD2RDF/trunk/xsl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CMDI-Interoperability/CMD2RDF/trunk/xsl/CMD2RDF.xsl

    r3792 r5310  
    7070    </xsl:function>
    7171   
     72    <!-- make sure we use a clean ID -->
     73    <xsl:function name="cmd:id">
     74        <xsl:param name="id"/>
     75        <xsl:sequence select="replace($id,'.*(clarin.eu:cr[0-9]+:p_[0-9]+).*','$1')"/>
     76    </xsl:function>
     77   
    7278    <!-- the registry URL for a profile -->
    7379    <xsl:function name="cmd:ppath">
    7480        <xsl:param name="id"/>
    7581        <xsl:param name="ext"/>
    76         <xsl:sequence select="concat($registry,'/rest/registry/profiles/',$id,'/',$ext)"/>
     82        <xsl:sequence select="concat($registry,'/rest/registry/profiles/',cmd:id($id),'/',$ext)"/>
    7783    </xsl:function>
    7884
     
    8187        <xsl:param name="id"/>
    8288        <xsl:param name="ext"/>
    83         <xsl:sequence select="concat($registry,'/rest/registry/components/',$id,'/',$ext)"/>
     89        <xsl:sequence select="concat($registry,'/rest/registry/components/',cmd:id($id),'/',$ext)"/>
    8490    </xsl:function>
    8591   
  • CMDI-Interoperability/CMD2RDF/trunk/xsl/CMD2RDFcache.xsl

    r5238 r5310  
    1313>
    1414   
    15     <xsl:include href="../../../../SMC/src/xsl/smc_commons.xsl"/>
     15    <xsl:include href="../../../SMC/src/src/xsl/smc_commons.xsl"/>
    1616   
    1717    <!-- load a profile from the registry -->
  • CMDI-Interoperability/CMD2RDF/trunk/xsl/CMDRecord2RDF.xsl

    r5237 r5310  
    77    <!ENTITY oa 'http://www.w3.org/ns/oa#'>
    88]>
    9 <xsl:stylesheet
    10     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    11     xmlns:dcr="http://www.isocat.org/ns/dcr.rdf#"
    12     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    13     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    14     xmlns:cmd="http://www.clarin.eu/cmd/"
    15     xmlns:cmdm="http://www.clarin.eu/cmd/general.rdf#"
    16     xmlns:ore="http://www.openarchives.org/ore/terms/"
    17     xmlns:oa="http://www.w3.org/ns/oa#"
    18     xmlns:dcterms="http://purl.org/dc/terms/"
    19     xmlns:dc="http://purl.org/dc/elements/1.1/"
    20 >
    21    
     9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:dcr="http://www.isocat.org/ns/dcr.rdf#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:cmd="http://www.clarin.eu/cmd/" xmlns:cmdm="http://www.clarin.eu/cmd/general.rdf#" xmlns:ore="http://www.openarchives.org/ore/terms/" xmlns:oa="http://www.w3.org/ns/oa#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     10
    2211    <xsl:output method="xml" encoding="UTF-8"/>
    23    
     12
    2413    <!-- allow to rewrite the urls -->
    2514    <xsl:param name="base_strip" select="base-uri()"/>
    2615    <xsl:param name="base_add" select="''"/>
    27    
     16
    2817    <xsl:variable name="about" select="replace(if ($base_strip=base-uri()) then base-uri() else replace(base-uri(), $base_strip, $base_add),'([./])(xml|cmdi)$','$1rdf')"/>
    29    
     18
    3019    <xsl:include href="CMD2RDF.xsl"/>
    31    
     20
    3221    <xsl:template match="text()"/>
    33    
     22
    3423    <!-- let's create some RDF -->
    3524    <xsl:template match="/cmd:CMD">
     
    4635                <xsl:apply-templates select="cmd:Resources" mode="other"/>
    4736            </oa:Annotation>
    48             <!-- The CMDI is an ORE ResourceMap to other metadata descriptions --> 
     37            <!-- The CMDI is an ORE ResourceMap to other metadata descriptions -->
    4938            <xsl:if test="exists(cmd:Resources/ResourceProxyList/ResourceProxy[ResourceType='Metadata'])">
    5039                <ore:ResourceMap rdf:about="{$about}">
     
    5948        </rdf:RDF>
    6049    </xsl:template>
    61    
     50
    6251    <xsl:template match="cmd:MdCreator">
    6352        <rdf:Description rdf:about="{concat('#',generate-id(/cmd:CMD/cmd:Components/*))}">
     
    7564        </rdf:Description>
    7665    </xsl:template>
    77    
     66
    7867    <xsl:template match="cmd:MdSelfLink">
    7968        <rdf:Description rdf:about="{concat('#',generate-id(/cmd:CMD/cmd:Components/*))}">
     
    8372        </rdf:Description>
    8473    </xsl:template>
    85    
     74
    8675    <xsl:template match="cmd:MdProfile">
    8776        <!-- TODO? -->
    8877    </xsl:template>
    89    
     78
    9079    <xsl:template match="cmd:MdCollectionDisplayName">
    9180        <!-- TODO -->
    9281    </xsl:template>
    93    
     82
    9483    <xsl:template match="text()" mode="resources"/>
    9584    <xsl:template match="cmd:ResourceProxy[cmd:ResourceType!='Resource']" mode="resources"/>
     
    10594        </oa:hasTarget>
    10695    </xsl:template>
    107    
     96
    10897    <xsl:template match="text()" mode="metadata"/>
    10998    <xsl:template match="cmd:ResourceProxy[cmd:ResourceType!='Metadata']" mode="metadata"/>
     
    129118        -->
    130119    </xsl:template>
    131    
     120
    132121    <!-- the CMD body -->
    133122    <xsl:template match="/cmd:CMD/cmd:Components">
    134123        <!-- get the profile id -->
    135                 <!-- and ignore if there are multiple MdProfile and just take the first!!
    136                         although probably this more a case for the schema validation!  -->
    137         <xsl:variable name="id" select="(/cmd:CMD/cmd:Header/cmd:MdProfile)[1]"/>
     124        <xsl:variable name="id">
     125            <xsl:choose>
     126                <xsl:when test="exists(/cmd:CMD/cmd:Header/cmd:MdProfile)">
     127                    <!-- and ignore if there are multiple MdProfile and just take the first!!
     128                         although probably this more a case for the schema validation!  -->
     129                    <xsl:sequence select="cmd:id((/cmd:CMD/cmd:Header/cmd:MdProfile)[1])"/>
     130                </xsl:when>
     131                <xsl:when test="exists(/cmd:CMD/@xsi:schemaLocation)">
     132                    <xsl:sequence select="cmd:id(/cmd:CMD/@xsi:schemaLocation)"/>
     133                </xsl:when>
     134                <xsl:otherwise>
     135                    <xsl:message terminate="yes">
     136                        <xsl:text>ERR: the CMDI record doesn't refer to its profile!</xsl:text>
     137                    </xsl:message>
     138                </xsl:otherwise>
     139            </xsl:choose>
     140        </xsl:variable>
     141        <if test="not(startsWith($id,'clarin.eu:'))">
     142            <xsl:text>ERR: the CMDI record doesn't refer to a profile in the CR!</xsl:text>
     143        </if>
    138144        <!-- load the profile -->
    139145        <xsl:variable name="profile" select="cmd:profile($id)"/>
     
    147153        </xsl:apply-templates>
    148154    </xsl:template>
    149    
     155
    150156    <!-- a CMD component -->
    151157    <xsl:template match="CMD_Component">
     
    212218    </xsl:template>
    213219
    214     <!-- a CMD element --> 
     220    <!-- a CMD element -->
    215221    <xsl:template match="CMD_Element">
    216222        <xsl:param name="context" tunnel="yes"/>
     
    254260        </xsl:for-each>
    255261    </xsl:template>
    256    
     262
    257263    <!-- a CMD attribute -->
    258264    <xsl:template match="Attribute">
  • CMDI-Interoperability/CMD2RDF/trunk/xsl/CMDRecord2RDFcache.xsl

    r5238 r5310  
    1818    xmlns:dcterms="http://purl.org/dc/terms/"
    1919    xmlns:dc="http://purl.org/dc/elements/1.1/"
     20    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    2021>
    2122   
     
    3132    <xsl:template match="/cmd:CMD/cmd:Components">
    3233        <!-- get the profile id -->
    33         <!-- and ignore if there are multiple MdProfile and just take the first!!
    34                         although probably this more a case for the schema validation!  -->
    35         <xsl:variable name="id" select="(/cmd:CMD/cmd:Header/cmd:MdProfile)[1]"/>
     34        <!-- get the profile id -->
     35        <xsl:variable name="id">
     36            <xsl:choose>
     37                <xsl:when test="exists(/cmd:CMD/cmd:Header/cmd:MdProfile)">
     38                    <!-- and ignore if there are multiple MdProfile and just take the first!!
     39                         although probably this more a case for the schema validation!  -->
     40                    <xsl:sequence select="cmd:id((/cmd:CMD/cmd:Header/cmd:MdProfile)[1])"/>
     41                </xsl:when>
     42                <xsl:when test="exists(/cmd:CMD/@xsi:schemaLocation)">
     43                    <xsl:sequence select="cmd:id(/cmd:CMD/@xsi:schemaLocation)"/>
     44                </xsl:when>
     45                <xsl:otherwise>
     46                    <xsl:message terminate="yes">
     47                        <xsl:text>ERR: the CMDI record doesn't refer to its profile!</xsl:text>
     48                    </xsl:message>
     49                </xsl:otherwise>
     50            </xsl:choose>
     51        </xsl:variable>
     52        <if test="not(startsWith($id,'clarin.eu:'))">
     53            <xsl:text>ERR: the CMDI record doesn't refer to a profile in the CR!</xsl:text>
     54        </if>
    3655        <!-- prefetch the profile into the cache on the fly.
    3756            the profile (if freshly fetched)  will however only be available in subsequent calls
Note: See TracChangeset for help on using the changeset viewer.