1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <xsl:stylesheet |
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
4 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
5 | xmlns:cmd="http://www.clarin.eu/cmd/" |
---|
6 | xmlns:fn="http://www.w3.org/2005/xpath-functions" |
---|
7 | exclude-result-prefixes="xs" |
---|
8 | version="2.0" |
---|
9 | xpath-default-namespace="http://www.clarin.eu/cmd/"> |
---|
10 | <!-- |
---|
11 | <!DOCTYPE html> |
---|
12 | --> |
---|
13 | |
---|
14 | <xsl:output |
---|
15 | method="html" |
---|
16 | encoding="UTF-8" |
---|
17 | doctype-system="about:legacy-compat" |
---|
18 | indent="yes" |
---|
19 | cdata-section-elements="td"/> |
---|
20 | |
---|
21 | <xsl:param |
---|
22 | name="prune_Components_branches_without_text_values" |
---|
23 | as="xs:boolean" |
---|
24 | select='false()'/> |
---|
25 | |
---|
26 | <xsl:template |
---|
27 | name="Component_tree" |
---|
28 | match="/CMD/Components"> |
---|
29 | <xsl:param |
---|
30 | name="nodeset" |
---|
31 | as="element()+" |
---|
32 | select="/CMD/Components"/> |
---|
33 | |
---|
34 | <ul> |
---|
35 | <xsl:for-each |
---|
36 | select="$nodeset/element()"> |
---|
37 | <xsl:variable |
---|
38 | name="subnodes_text" |
---|
39 | select="fn:normalize-space(fn:string-join(descendant-or-self::element()/text(), ''))" as="xs:string+"/> |
---|
40 | <xsl:if |
---|
41 | test="not($subnodes_text = '' and $prune_Components_branches_without_text_values)"> |
---|
42 | <xsl:variable |
---|
43 | name="nchildren" |
---|
44 | select="fn:count(child::element())"/> |
---|
45 | <li> |
---|
46 | |
---|
47 | <code class="node"> |
---|
48 | <xsl:value-of |
---|
49 | select="fn:concat(local-name(), ' ')"/> |
---|
50 | <xsl:if |
---|
51 | test="count(@*) > 0"> |
---|
52 | <div class="attributes"> |
---|
53 | <xsl:for-each |
---|
54 | select="@*"> |
---|
55 | <xsl:value-of |
---|
56 | select="name()"/>="<xsl:value-of select="."/>" |
---|
57 | </xsl:for-each> |
---|
58 | </div> |
---|
59 | </xsl:if> |
---|
60 | </code> |
---|
61 | |
---|
62 | <xsl:choose> |
---|
63 | <xsl:when |
---|
64 | test="$nchildren = 0 and not(not(child::node()))"> |
---|
65 | <!--<br /><br />--> |
---|
66 | <div class="Component_tree_node_content"> |
---|
67 | <xsl:choose> |
---|
68 | <xsl:when |
---|
69 | test="self::element() castable as xs:string"> |
---|
70 | <xsl:variable |
---|
71 | name="leaf_value" |
---|
72 | select="self::element() cast as xs:string" |
---|
73 | as="xs:string"/> |
---|
74 | <xsl:variable |
---|
75 | name="is_URL" |
---|
76 | select="starts-with($leaf_value, 'http://') or starts-with($leaf_value, 'https://')" |
---|
77 | as="xs:boolean"/> |
---|
78 | <code class="leaf"> |
---|
79 | <xsl:choose> |
---|
80 | <xsl:when |
---|
81 | test="$is_URL"> |
---|
82 | <a href="{$leaf_value}"> |
---|
83 | <xsl:value-of |
---|
84 | select="$leaf_value"/> |
---|
85 | </a> |
---|
86 | </xsl:when> |
---|
87 | <xsl:otherwise> |
---|
88 | <xsl:value-of |
---|
89 | select="$leaf_value"/> |
---|
90 | </xsl:otherwise> |
---|
91 | </xsl:choose> |
---|
92 | </code> |
---|
93 | </xsl:when> |
---|
94 | <xsl:otherwise> |
---|
95 | <xsl:variable |
---|
96 | name="leaf_value" |
---|
97 | select="format-number(self::element(), '#') cast as xs:string" |
---|
98 | as="xs:string"/> |
---|
99 | <xsl:variable |
---|
100 | name="is_URL" |
---|
101 | select="starts-with($leaf_value, 'http://') or starts-with($leaf_value, 'https://')" |
---|
102 | as="xs:boolean"/> |
---|
103 | <code class="leaf"> |
---|
104 | <xsl:choose> |
---|
105 | <xsl:when |
---|
106 | test="$is_URL"> |
---|
107 | <a href="{$leaf_value}"><xsl:value-of select="$leaf_value"/></a> |
---|
108 | </xsl:when> |
---|
109 | <xsl:otherwise> |
---|
110 | <xsl:value-of |
---|
111 | select="$leaf_value"/> |
---|
112 | </xsl:otherwise> |
---|
113 | </xsl:choose> |
---|
114 | </code> |
---|
115 | </xsl:otherwise> |
---|
116 | </xsl:choose> |
---|
117 | </div> |
---|
118 | </xsl:when> |
---|
119 | <xsl:otherwise> |
---|
120 | <ul> |
---|
121 | <xsl:call-template |
---|
122 | name="Component_tree"> |
---|
123 | <xsl:with-param |
---|
124 | name="nodeset" |
---|
125 | select="self::element()"/> |
---|
126 | </xsl:call-template> |
---|
127 | </ul> |
---|
128 | </xsl:otherwise> |
---|
129 | </xsl:choose> |
---|
130 | |
---|
131 | </li> |
---|
132 | </xsl:if> |
---|
133 | </xsl:for-each> |
---|
134 | </ul> |
---|
135 | </xsl:template> |
---|
136 | |
---|
137 | <xsl:template match="CMD"> |
---|
138 | <article style="background-color:#EEEEEE"> |
---|
139 | <div class="endgame"> |
---|
140 | <xsl:if test="not(not(Resources/*[normalize-space()]))"> |
---|
141 | <p> |
---|
142 | <h1>Resources</h1> |
---|
143 | <table> |
---|
144 | <caption>Resources</caption> |
---|
145 | <thead> |
---|
146 | <tr> |
---|
147 | <th class="attribute">Reference to resource</th> |
---|
148 | <th class="attribute">Resource description</th> |
---|
149 | <th class="attribute">Resource MIME type</th> |
---|
150 | <th class="attribute">Resource Proxy ID</th> |
---|
151 | </tr> |
---|
152 | </thead> |
---|
153 | <tbody class="attributesTbody"> |
---|
154 | <xsl:for-each |
---|
155 | select="Resources/ResourceProxyList/ResourceProxy"> |
---|
156 | <xsl:variable |
---|
157 | name="URI" |
---|
158 | select="ResourceRef/text()" |
---|
159 | as="xs:string"/> |
---|
160 | <tr> |
---|
161 | <td class="attributeValue"> |
---|
162 | <xsl:variable |
---|
163 | name="protocol" |
---|
164 | select="fn:substring-before($URI, ':')" |
---|
165 | as="xs:string"/> |
---|
166 | <xsl:choose> |
---|
167 | <xsl:when |
---|
168 | test="$protocol = 'hdl'"> |
---|
169 | <xsl:variable |
---|
170 | name="HANDLE_PREFIX" |
---|
171 | select="'http://hdl.handle.net'" |
---|
172 | as="xs:string"/> |
---|
173 | <xsl:variable |
---|
174 | name="Handle_reference" |
---|
175 | select="fn:substring-after($URI, ':')" |
---|
176 | as="xs:string"/> |
---|
177 | <xsl:variable |
---|
178 | name="Handle_HTTP_URL" |
---|
179 | select="fn:concat($HANDLE_PREFIX, '/', $Handle_reference)" |
---|
180 | as="xs:string"/> |
---|
181 | <a href="{$Handle_HTTP_URL}"> |
---|
182 | <xsl:value-of |
---|
183 | select="$Handle_HTTP_URL"/> |
---|
184 | </a> |
---|
185 | </xsl:when> |
---|
186 | <xsl:otherwise> |
---|
187 | <a href="{ResourceRef}"> |
---|
188 | <xsl:value-of |
---|
189 | select="ResourceRef"/> |
---|
190 | </a> |
---|
191 | </xsl:otherwise> |
---|
192 | </xsl:choose> |
---|
193 | </td> |
---|
194 | <td class="attributeValue"> |
---|
195 | <xsl:value-of select="ResourceType"/> |
---|
196 | </td> |
---|
197 | <td class="attributeValue"> |
---|
198 | <xsl:value-of select="ResourceType/@mimetype"/> |
---|
199 | </td> |
---|
200 | <td class="attributeValue"> |
---|
201 | <xsl:value-of select="./@id"/> |
---|
202 | </td> |
---|
203 | </tr> |
---|
204 | </xsl:for-each> |
---|
205 | </tbody> |
---|
206 | </table> |
---|
207 | </p> |
---|
208 | </xsl:if> |
---|
209 | </div> |
---|
210 | |
---|
211 | <p> |
---|
212 | <h1>Metadata content</h1> |
---|
213 | <xsl:call-template name="Component_tree"/> |
---|
214 | </p> |
---|
215 | </article> |
---|
216 | </xsl:template> |
---|
217 | </xsl:stylesheet> |
---|