Skip to content

Commit a7b0e8b

Browse files
fluetzekkrebs
authored andcommitted
MCR-3497 Re-add items2options.xsl under xsl/ folder
1 parent 63f03c8 commit a7b0e8b

1 file changed

Lines changed: 132 additions & 0 deletions

File tree

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3+
<!-- Transforms output of "classification:editorComplete:*" URIs to xeditor compatible format -->
4+
<xsl:param name="CurrentLang" />
5+
<xsl:param name="DefaultLang" />
6+
<xsl:param name="MaxLengthVisible" />
7+
<xsl:param name="Mode" />
8+
<xsl:param name="allSelectable" select="'false'" />
9+
10+
<xsl:variable name="editor.list.indent" select="'&#160;&#160;&#160;'" />
11+
<xsl:template match="items">
12+
<xsl:choose>
13+
<xsl:when test="$Mode='editor'">
14+
<xsl:apply-templates select="." mode="editor" />
15+
</xsl:when>
16+
<xsl:otherwise>
17+
<select>
18+
<xsl:copy-of select="@*" />
19+
<xsl:apply-templates />
20+
</select>
21+
</xsl:otherwise>
22+
</xsl:choose>
23+
</xsl:template>
24+
25+
<xsl:template match="item">
26+
<xsl:param name="indent" select="''" />
27+
28+
<xsl:variable name="toolTip">
29+
<xsl:apply-templates select="." mode="toolTip" />
30+
</xsl:variable>
31+
32+
<xsl:choose>
33+
<xsl:when test="label[lang('x-group')] and not($allSelectable='true')">
34+
<optgroup title="{$toolTip}">
35+
<xsl:attribute name="label">
36+
<xsl:value-of select="$indent" disable-output-escaping="yes" />
37+
<xsl:apply-templates select="." mode="label" />
38+
</xsl:attribute>
39+
<xsl:copy-of select="@*" />
40+
<xsl:apply-templates select="item">
41+
<xsl:with-param name="indent" select="concat($editor.list.indent,$indent)" />
42+
</xsl:apply-templates>
43+
</optgroup>
44+
</xsl:when>
45+
<xsl:otherwise>
46+
<option title="{$toolTip}">
47+
<xsl:if test="label[lang('x-disable')] and not($allSelectable='true')">
48+
<xsl:attribute name="disabled"/>
49+
</xsl:if>
50+
<xsl:copy-of select="@*" />
51+
<xsl:value-of select="$indent" disable-output-escaping="yes" />
52+
<xsl:apply-templates select="." mode="label" />
53+
</option>
54+
<xsl:apply-templates select="item">
55+
<xsl:with-param name="indent" select="concat($editor.list.indent,$indent)" />
56+
</xsl:apply-templates>
57+
</xsl:otherwise>
58+
</xsl:choose>
59+
60+
</xsl:template>
61+
62+
<xsl:template match="item" mode="label">
63+
<xsl:variable name="onDisplay">
64+
<xsl:choose>
65+
<xsl:when test="label[lang($CurrentLang)]">
66+
<xsl:value-of select="label[lang($CurrentLang)]" />
67+
</xsl:when>
68+
<xsl:when test="label[lang($DefaultLang)]">
69+
<xsl:value-of select="label[lang($DefaultLang)]" />
70+
</xsl:when>
71+
<xsl:otherwise>
72+
<xsl:value-of select="label[1]" />
73+
</xsl:otherwise>
74+
</xsl:choose>
75+
</xsl:variable>
76+
77+
<xsl:call-template name="shorten">
78+
<xsl:with-param name="onDisplay" select="$onDisplay" />
79+
</xsl:call-template>
80+
</xsl:template>
81+
82+
<xsl:template match="item" mode="toolTip">
83+
<xsl:choose>
84+
<xsl:when test="label[lang($CurrentLang)]">
85+
<xsl:value-of select="label[lang($CurrentLang)]" />
86+
</xsl:when>
87+
<xsl:when test="label[lang($DefaultLang)]">
88+
<xsl:value-of select="label[lang($DefaultLang)]" />
89+
</xsl:when>
90+
<xsl:otherwise>
91+
<xsl:value-of select="." />
92+
</xsl:otherwise>
93+
</xsl:choose>
94+
</xsl:template>
95+
96+
<xsl:template match="items" mode="editor">
97+
<items>
98+
<xsl:apply-templates mode="editor" />
99+
</items>
100+
</xsl:template>
101+
102+
<xsl:template match="item" mode="editor">
103+
<item value="{@value}">
104+
<xsl:for-each select="label">
105+
<xsl:apply-templates select="." mode="editor" />
106+
</xsl:for-each>
107+
<!-- ==== handle children ==== -->
108+
<xsl:apply-templates select="item" mode="editor" />
109+
</item>
110+
</xsl:template>
111+
112+
<xsl:template match="label" mode="editor">
113+
<label xml:lang="{@xml:lang}">
114+
<xsl:call-template name="shorten">
115+
<xsl:with-param name="onDisplay" select="." />
116+
</xsl:call-template>
117+
</label>
118+
</xsl:template>
119+
120+
<xsl:template name="shorten">
121+
<xsl:param name="onDisplay" />
122+
<xsl:choose>
123+
<xsl:when test="$MaxLengthVisible and (string-length($onDisplay) &gt; $MaxLengthVisible) ">
124+
<xsl:value-of select="concat(substring($onDisplay, 0, $MaxLengthVisible), ' [...]')" />
125+
</xsl:when>
126+
<xsl:otherwise>
127+
<xsl:value-of select="$onDisplay" />
128+
</xsl:otherwise>
129+
</xsl:choose>
130+
</xsl:template>
131+
132+
</xsl:stylesheet>

0 commit comments

Comments
 (0)