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-toolkit" select="'../../../../../main/resources/toolkit'"/> |
---|
10 | <xsl:param name="cmd-component-xsd" select="concat($cmd-toolkit,'/xsd/cmd-component.xsd')"/> |
---|
11 | <xsl:param name="cmd-component-status" select="'production'"/> |
---|
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="@* except @Documentation"/> |
---|
21 | <xsl:apply-templates select="@Documentation"/> |
---|
22 | <xsl:apply-templates select="node()"/> |
---|
23 | </xsl:copy> |
---|
24 | </xsl:template> |
---|
25 | |
---|
26 | <!-- refer to cmd-component.xsd --> |
---|
27 | <xsl:template match="@xsi:schemaLocation" priority="1"> |
---|
28 | <xsl:attribute name="xsi:noNamespaceSchemaLocation" select="$cmd-component-xsd"/> |
---|
29 | </xsl:template> |
---|
30 | |
---|
31 | <!-- get rid of CMD_ prefix --> |
---|
32 | <xsl:template match="CMD_ComponentSpec" priority="1"> |
---|
33 | <ComponentSpec> |
---|
34 | <xsl:apply-templates select="@*|node()"/> |
---|
35 | </ComponentSpec> |
---|
36 | </xsl:template> |
---|
37 | |
---|
38 | <xsl:template match="CMD_Component" priority="1"> |
---|
39 | <Component> |
---|
40 | <xsl:apply-templates select="@*|node()"/> |
---|
41 | </Component> |
---|
42 | </xsl:template> |
---|
43 | |
---|
44 | <xsl:template match="CMD_Element" priority="1"> |
---|
45 | <Element> |
---|
46 | <xsl:apply-templates select="@* except @Documentation"/> |
---|
47 | <xsl:apply-templates select="@Documentation"/> |
---|
48 | <xsl:apply-templates select="node()"/> |
---|
49 | </Element> |
---|
50 | </xsl:template> |
---|
51 | |
---|
52 | <!-- add Status --> |
---|
53 | <xsl:template match="Header" priority="1"> |
---|
54 | <xsl:copy> |
---|
55 | <xsl:apply-templates select="@*|node()"/> |
---|
56 | <Status> |
---|
57 | <xsl:value-of select="$cmd-component-status"/> |
---|
58 | </Status> |
---|
59 | </xsl:copy> |
---|
60 | </xsl:template> |
---|
61 | |
---|
62 | <!-- turn @Documentation into <Documentation/> --> |
---|
63 | <xsl:template match="@Documentation" priority="1"> |
---|
64 | <Documentation> |
---|
65 | <xsl:value-of select="."/> |
---|
66 | </Documentation> |
---|
67 | </xsl:template> |
---|
68 | |
---|
69 | <!-- add Vocabulary level --> |
---|
70 | <xsl:template match="enumeration" priority="1"> |
---|
71 | <Vocabulary> |
---|
72 | <enumeration> |
---|
73 | <xsl:apply-templates select="@*|node()"/> |
---|
74 | </enumeration> |
---|
75 | </Vocabulary> |
---|
76 | </xsl:template> |
---|
77 | |
---|
78 | <!-- turn Attribute child elements into attributes --> |
---|
79 | <xsl:template match="Attribute" priority="1"> |
---|
80 | <Attribute name="{Name}"> |
---|
81 | <xsl:if test="normalize-space(Type)!=''"> |
---|
82 | <xsl:attribute name="ValueScheme" select="Type"/> |
---|
83 | </xsl:if> |
---|
84 | <xsl:if test="normalize-space(ConceptLink)!=''"> |
---|
85 | <xsl:attribute name="ConceptLink" select="ConceptLink"/> |
---|
86 | </xsl:if> |
---|
87 | <xsl:apply-templates select="* except Name except Type except ConceptLink"/> |
---|
88 | </Attribute> |
---|
89 | </xsl:template> |
---|
90 | |
---|
91 | <!-- put DisplayPriority in the cues namespace --> |
---|
92 | <xsl:template match="@DisplayPriority" priority="1"> |
---|
93 | <xsl:attribute name="cue:DisplayPriority"> |
---|
94 | <xsl:value-of select="."/> |
---|
95 | </xsl:attribute> |
---|
96 | </xsl:template> |
---|
97 | |
---|
98 | </xsl:stylesheet> |
---|