source: metadata/trunk/toolkit/src/main/resources/toolkit/downgrade/cmd-component-1_2-to-1_1.xsl @ 6925

Last change on this file since 6925 was 6925, checked in by Menzo Windhouwer, 8 years ago

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

  • added @CMDVersion and @CMDOriginalVersion

M toolkit/src/test/resources/toolkit/CMD/profiles/components-invalid.xml
M toolkit/src/test/resources/toolkit/successor/profiles/successor-valid.xml
M toolkit/src/test/resources/toolkit/successor/profiles/successor-invalid.xml
M toolkit/src/test/resources/toolkit/Adelheid/profiles/clarin.eu:cr1:p_1311927752306_1_2.xml

  • added @CMDVersion="1.2"

AM toolkit/src/test/resources/temp/general-component-schema.xsd

  • temporary CMDI 1.1 component schema containing the xsl:key optimization

-> speeds up the CMDI 1.2 downgrade tests

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

  • check if the profile is native CMD 1.2 so we need to refer to the 1.1/1.2/xsd
  • for testing purposes the profile spec can also be passed as a parameter, if not its fetched from the CR
  • the XPaths dealing with the profiles cope with both 1.1 and 1.2

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

  • pass on the profile spec to the upgrade record actions
  • use the temporary 1.1 general-component-schema.xsd for the downgrade tests
File size: 5.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4    xmlns:xs="http://www.w3.org/2001/XMLSchema"
5    xmlns:cue="http://www.clarin.eu/cmdi/cues/1"
6    exclude-result-prefixes="xs"
7    version="2.0">
8
9    <xsl:param name="cmd-component-xsd" select="'http://infra.clarin.eu/cmd/general-component-schema.xsd'"/>
10   
11    <xsl:param name="escape" select="'ccmmddii_'"/>
12   
13    <!-- identity copy -->
14    <xsl:template match="@*">
15        <xsl:copy/>
16    </xsl:template>
17   
18    <xsl:template match="node()">
19        <xsl:copy>
20            <xsl:apply-templates select="@*|node()"/>
21        </xsl:copy>
22    </xsl:template>
23
24    <!-- refer to cmd-component.xsd -->
25    <xsl:template match="@xsi:noNamespaceSchemaLocation" priority="1">
26        <xsl:attribute name="xsi:noNamespaceSchemaLocation" select="$cmd-component-xsd"/>
27    </xsl:template>
28
29    <!-- add CMD_ prefix -->
30    <xsl:template match="ComponentSpec" priority="1">
31        <CMD_ComponentSpec>
32            <xsl:apply-templates select="@*|node()"/>
33        </CMD_ComponentSpec>
34    </xsl:template>
35
36    <xsl:template match="Component" priority="1">
37        <CMD_Component>
38            <xsl:apply-templates select="@*|node()"/>
39        </CMD_Component>
40    </xsl:template>
41   
42    <xsl:template match="Element" priority="1">
43        <CMD_Element>
44            <xsl:apply-templates select="@*"/>
45            <xsl:apply-templates select="Documentation"/>
46            <xsl:apply-templates select="node() except Documentation"/>
47        </CMD_Element>
48    </xsl:template>
49   
50    <!-- remove CDM version attributes -->
51    <xsl:template match="ComponentSpec/@CMDVersion"/>
52    <xsl:template match="ComponentSpec/@CMDOriginalVersion"/>
53   
54    <!-- remove Status and friends -->
55    <xsl:template match="Header/Status" priority="1"/>
56    <xsl:template match="Header/StatusComment" priority="1"/>
57    <xsl:template match="Header/Successor" priority="1"/>
58   
59    <!-- turn <Documentation/> into @Documentation -->
60    <xsl:template match="Documentation" priority="1">
61        <xsl:choose>
62            <xsl:when test="exists(../Documentation[@xml:lang=('en','eng')])">
63                <xsl:if test="@xml:lang=('en','eng') and empty(preceding-sibling::Documentation[@xml:lang=('en','eng')])">
64                    <!-- first english documentation -->
65                    <xsl:attribute name="Documentation" select="."/>
66                </xsl:if>
67            </xsl:when>
68            <xsl:when test="exists(../Documentation[normalize-space(@xml:lang)=''])">
69                <xsl:if test="normalize-space(@xml:lang)='' and empty(preceding-sibling::Documentation[normalize-space(@xml:lang)=''])">
70                    <!-- first general documentation -->
71                    <xsl:attribute name="Documentation" select="."/>
72                </xsl:if>
73            </xsl:when>
74            <xsl:when test="empty(preceding-sibling::Documentation)">
75                <!-- first documentation -->
76                <xsl:attribute name="Documentation" select="."/>
77            </xsl:when>
78        </xsl:choose>
79    </xsl:template>
80
81    <!-- remove Vocabulary level, incl. attributes -->
82    <xsl:template match="Vocabulary" priority="1">
83        <xsl:apply-templates select="node()"/>
84    </xsl:template>
85   
86    <!-- turn Attribute child elements into attributes -->
87    <xsl:template match="Attribute" priority="1">
88        <xsl:variable name="name">
89            <xsl:choose>
90                <xsl:when test="exists(parent::AttributeList/parent::Component) and Name=('ref','ComponentId')">
91                    <xsl:message>WRN: user-defined ref and ComponentId attributes for a Component are not supported by CMDI 1.1! Adding the <xsl:value-of select="$escape"/> prefix</xsl:message>
92                    <xsl:value-of select="concat($escape,@name)"/>
93                </xsl:when>
94                <xsl:otherwise>
95                    <xsl:value-of select="@name"/>
96                </xsl:otherwise>
97            </xsl:choose>
98        </xsl:variable>
99        <Attribute>
100            <Name>
101                <xsl:value-of select="$name"/>
102            </Name>
103            <xsl:if test="normalize-space(@ConceptLink)!=''">
104                <ConceptLink>
105                    <xsl:value-of select="@ConceptLink"/>
106                </ConceptLink>
107            </xsl:if>
108            <xsl:if test="normalize-space(@ValueScheme)!=''">
109                <Type>
110                    <xsl:value-of select="@ValueScheme"/>
111                </Type>
112            </xsl:if>
113            <!-- @Required is skipped -->
114            <xsl:apply-templates select="node()"/>
115        </Attribute>
116    </xsl:template>
117   
118    <!-- remove cue namespace for DisplayPriority -->
119    <xsl:template match="@cue:DisplayPriority" priority="2">
120        <xsl:attribute name="DisplayPriority">
121            <xsl:value-of select="."/>
122        </xsl:attribute>
123    </xsl:template>
124   
125    <!-- remove other cue attributes -->
126    <xsl:template match="@cue:*" priority="1"/>
127
128</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.