Ignore:
Timestamp:
01/14/16 12:05:44 (9 years ago)
Author:
Menzo Windhouwer
Message:

M toolkit/src/main/resources/toolkit/upgrade/cmd-record-1_1-to-1_2.xsl

  • unescaped escaped CMDI 1.2 attributes
  • warn when a @ref contains multiple resource proxy references, and use only the first one

M toolkit/src/main/resources/toolkit/downgrade/cmd-component-1_2-to-1_1.xsl

  • escape attributes that would clash with CMDI 1.1 reserved attributes

M toolkit/src/main/resources/toolkit/xsd/cmd-component.xsd
A toolkit/src/main/resources/toolkit/sch/cmd-component-best-practices.sch

  • moved Schematron rules which are validate best practices

M toolkit/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java

  • removed obsolete commented out code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • metadata/trunk/toolkit/src/main/resources/toolkit/upgrade/cmd-record-1_1-to-1_2.xsl

    r6751 r6907  
    1212    <xsl:param name="cmd-uri" select="'http://www.clarin.eu/cmd/1'"/>
    1313    <xsl:param name="cr-uri" select="'..'"/>
     14    <xsl:param name="cr-extension-xsd" select="'-1_2.xsd'"/>
     15    <xsl:param name="cr-extension-xml" select="'.xml'"/>
     16   
     17    <xsl:param name="escape" select="'ccmmddii_'"/>
    1418   
    1519    <xsl:variable name="cmd-components" select="concat($cmd-uri,'/components')"/>
    1620    <xsl:variable name="cmd-profiles" select="concat($cmd-uri,'/profiles')"/>
    1721    <xsl:variable name="cr-profiles" select="concat($cr-uri,'/profiles')"/>
    18     <xsl:variable name="cr-extension-xsd" select="'-1_2.xsd'"/>
    19     <xsl:variable name="cr-extension-xml" select="'.xml'"/>
    2022   
    2123    <!-- identity copy -->
     
    147149    </xsl:template>
    148150   
     151    <!-- unescape downgraded CMDI 1.2 attributes -->
     152    <xsl:template match="cmd0:Components//@*[name()=local-name()][starts-with(name(),$escape)]">
     153        <xsl:attribute name="{substring-after(name(),$escape)}" select="."/>
     154    </xsl:template>
     155   
    149156    <!-- move CMD attributes to the CMD namespace -->
    150     <xsl:template match="cmd0:Components//@ref">
     157    <xsl:template match="cmd0:Components//@ref" priority="2">
    151158        <xsl:choose>
    152159            <xsl:when test="exists(parent::*/text()[normalize-space()!=''])">
     
    158165                <!-- the parent is a component add the namespace to @ref -->
    159166                <!--<xsl:message>INF: this is an component add the namespace to ref</xsl:message>-->
    160                 <xsl:attribute name="cmd:ref" select="."/>
     167                <xsl:attribute name="cmd:ref">
     168                    <xsl:variable name="refs" select="tokenize(.,'\s+')"/>
     169                    <xsl:if test="count($refs) gt 1">
     170                        <xsl:message>WRN: CMDI 1.2 doesn't support references to multiple ResourceProxies! Only the first reference is kept.</xsl:message>
     171                    </xsl:if>
     172                    <xsl:value-of select="$refs[1]"/>
     173                </xsl:attribute>
    161174            </xsl:when>
    162175            <xsl:otherwise>
     
    175188                        <!-- this is an undeclared @ref, so add the namespace -->
    176189                        <!--<xsl:message>INF: according to the profile this @ref is not user defined, so add the namespace</xsl:message>-->
    177                         <xsl:attribute name="cmd:ref" select="."/>
     190                        <xsl:attribute name="cmd:ref">
     191                            <xsl:variable name="refs" select="tokenize(.,'\s+')"/>
     192                            <xsl:if test="count($refs) gt 1">
     193                                <xsl:message>WRN: CMDI 1.2 doesn't support references to multiple ResourceProxies! Only the first reference is kept.</xsl:message>
     194                            </xsl:if>
     195                            <xsl:value-of select="$refs[1]"/>
     196                        </xsl:attribute>
    178197                    </xsl:otherwise>
    179198                </xsl:choose>
     
    182201    </xsl:template>
    183202   
    184     <xsl:template match="cmd0:Components//@ComponentId">
     203    <xsl:template match="cmd0:Components//@ComponentId" priority="2">
    185204        <xsl:attribute name="cmd:ComponentId" select="."/>
    186205    </xsl:template>
Note: See TracChangeset for help on using the changeset viewer.