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