1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
3 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
4 | xmlns:cmd="http://www.clarin.eu/cmd/" |
---|
5 | xmlns:fn="http://www.w3.org/2005/xpath-functions" |
---|
6 | exclude-result-prefixes="xs" |
---|
7 | version="2.0" |
---|
8 | xpath-default-namespace="http://www.clarin.eu/cmd/"> |
---|
9 | <!-- |
---|
10 | <!DOCTYPE html> |
---|
11 | --> |
---|
12 | |
---|
13 | <xsl:output |
---|
14 | method="html" |
---|
15 | encoding="UTF-8" |
---|
16 | doctype-system="about:legacy-compat" |
---|
17 | indent="yes" |
---|
18 | cdata-section-elements="td"/> |
---|
19 | |
---|
20 | <xsl:param name="prune_Components_branches_without_text_values" as="xs:boolean" select='false()'/> |
---|
21 | |
---|
22 | |
---|
23 | <xsl:template name="Component_tree" match="/CMD/Components"> |
---|
24 | <xsl:param name="nodeset" as="element()+" select="/CMD/Components"/> |
---|
25 | |
---|
26 | <ul> |
---|
27 | <xsl:for-each select="$nodeset/element()"> |
---|
28 | <xsl:variable name="subnodes_text" select="fn:normalize-space(fn:string-join(descendant-or-self::element()/text(), ''))" as="xs:string+"/> |
---|
29 | <xsl:if test="not($subnodes_text = '' and $prune_Components_branches_without_text_values)"> |
---|
30 | <xsl:variable name="nchildren" select="fn:count(child::element())"/> |
---|
31 | <li> |
---|
32 | |
---|
33 | <code class="node"> |
---|
34 | <xsl:value-of select="fn:concat(local-name(), ' ')"/> |
---|
35 | <xsl:if test="count(@*) > 0"> |
---|
36 | <div class="attributes"> |
---|
37 | <xsl:for-each select="@*"> |
---|
38 | <xsl:value-of select="name()"/>="<xsl:value-of select="."/>" |
---|
39 | </xsl:for-each> |
---|
40 | </div> |
---|
41 | </xsl:if> |
---|
42 | </code> |
---|
43 | |
---|
44 | <xsl:choose> |
---|
45 | <xsl:when test="$nchildren = 0 and not(not(child::node()))"> |
---|
46 | <!--<br /><br />--> |
---|
47 | <div class="Component_tree_node_content"> |
---|
48 | <!-- --> |
---|
49 | <xsl:choose> |
---|
50 | <xsl:when test="self::element() castable as xs:string"> |
---|
51 | <xsl:variable name="leaf_value" |
---|
52 | select="self::element() cast as xs:string" |
---|
53 | as="xs:string"/> |
---|
54 | |
---|
55 | <xsl:variable name="HTTP_URL" |
---|
56 | select="starts-with($leaf_value, 'http://')" as="xs:boolean"/> |
---|
57 | <code class="leaf"> |
---|
58 | <xsl:choose> |
---|
59 | <xsl:when test="$HTTP_URL"> |
---|
60 | <a href="{$leaf_value}"><xsl:value-of select="$leaf_value"/></a> |
---|
61 | </xsl:when> |
---|
62 | <xsl:otherwise> |
---|
63 | <xsl:value-of select="$leaf_value"/> |
---|
64 | </xsl:otherwise> |
---|
65 | </xsl:choose> |
---|
66 | </code> |
---|
67 | </xsl:when> |
---|
68 | <xsl:otherwise> |
---|
69 | <xsl:variable name="leaf_value" |
---|
70 | select="format-number(self::element(), '#') cast as xs:string" |
---|
71 | as="xs:string"/> |
---|
72 | |
---|
73 | <xsl:variable name="HTTP_URL" |
---|
74 | select="starts-with($leaf_value, 'http://')" as="xs:boolean"/> |
---|
75 | <code class="leaf"> |
---|
76 | <xsl:choose> |
---|
77 | <xsl:when test="$HTTP_URL"> |
---|
78 | <a href="{$leaf_value}"><xsl:value-of select="$leaf_value"/></a> |
---|
79 | </xsl:when> |
---|
80 | <xsl:otherwise> |
---|
81 | <xsl:value-of select="$leaf_value"/> |
---|
82 | </xsl:otherwise> |
---|
83 | </xsl:choose> |
---|
84 | </code> |
---|
85 | </xsl:otherwise> |
---|
86 | </xsl:choose> |
---|
87 | </div> |
---|
88 | </xsl:when> |
---|
89 | <xsl:otherwise> |
---|
90 | <ul> |
---|
91 | <xsl:call-template name="Component_tree"> |
---|
92 | <xsl:with-param name="nodeset" |
---|
93 | select="self::element()"/> |
---|
94 | </xsl:call-template> |
---|
95 | </ul> |
---|
96 | </xsl:otherwise> |
---|
97 | </xsl:choose> |
---|
98 | |
---|
99 | </li> |
---|
100 | </xsl:if> |
---|
101 | </xsl:for-each> |
---|
102 | </ul> |
---|
103 | </xsl:template> |
---|
104 | |
---|
105 | |
---|
106 | <xsl:template match="CMD"> |
---|
107 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
---|
108 | <meta charset="utf-8"/> |
---|
109 | <head> |
---|
110 | <title>CMDI collection "<xsl:value-of select="./Header/MdCollectionDisplayName" xmlns="cmd"/>"</title> |
---|
111 | <link rel="stylesheet" type="text/css" href="http://catalog.clarin.eu/ds/vlo/css/main.css"></link> |
---|
112 | |
---|
113 | <style media="screen" type="text/css"> |
---|
114 | <![CDATA[ |
---|
115 | li |
---|
116 | { |
---|
117 | margin: 20px; |
---|
118 | margin-left: -1.2em; |
---|
119 | } |
---|
120 | |
---|
121 | .node |
---|
122 | { |
---|
123 | background-color: rgba(188, 205, 232, 0.8); |
---|
124 | border: 1px ridge; |
---|
125 | font-weight: bold; |
---|
126 | padding: 5px; |
---|
127 | /*float: left;*/ |
---|
128 | } |
---|
129 | |
---|
130 | .leaf |
---|
131 | { |
---|
132 | } |
---|
133 | |
---|
134 | .Component_tree_node_content |
---|
135 | { |
---|
136 | background-color: rgba(188, 200, 232, 0.3); |
---|
137 | border: 1px dotted red; |
---|
138 | margin-top: 10px; |
---|
139 | margin-left: 10px; |
---|
140 | padding: 5px; |
---|
141 | display: inline-block; |
---|
142 | /*float: left;*/ |
---|
143 | /*display: table-cell;*/ |
---|
144 | } |
---|
145 | |
---|
146 | .attributes |
---|
147 | { |
---|
148 | display: inline-block; |
---|
149 | font-style: italic; |
---|
150 | font-weight: normal; |
---|
151 | /*background-color: rgba(100, 201, 234, 0.4);*/ |
---|
152 | } |
---|
153 | |
---|
154 | footer |
---|
155 | { |
---|
156 | border: 1px dotted; |
---|
157 | } |
---|
158 | |
---|
159 | address |
---|
160 | { |
---|
161 | display: inline-block; |
---|
162 | } |
---|
163 | ]]> |
---|
164 | </style> |
---|
165 | </head> |
---|
166 | <body> |
---|
167 | <article> |
---|
168 | <div class="endgame"> |
---|
169 | <xsl:if test="not(not(Resources/*[normalize-space()]))"> |
---|
170 | <p> |
---|
171 | <h1>Resources</h1> |
---|
172 | <table> |
---|
173 | <caption>Resources</caption> |
---|
174 | <thead> |
---|
175 | <tr> |
---|
176 | <th class="attribute">Reference to resource</th> |
---|
177 | <th class="attribute">Resource description</th> |
---|
178 | <th class="attribute">Resource MIME type</th> |
---|
179 | <th class="attribute">Resource Proxy ID</th> |
---|
180 | </tr> |
---|
181 | </thead> |
---|
182 | <tbody class="attributesTbody"> |
---|
183 | <xsl:for-each select="Resources/ResourceProxyList/ResourceProxy"> |
---|
184 | <xsl:variable name="URI" select="ResourceRef/text()" as="xs:string"/> |
---|
185 | <tr> |
---|
186 | <td class="attributeValue"> |
---|
187 | <xsl:variable name="protocol" select="fn:substring-before($URI, ':')" as="xs:string"/> |
---|
188 | <xsl:choose> |
---|
189 | <xsl:when test="$protocol = 'hdl'"> |
---|
190 | <xsl:variable name="HANDLE_PREFIX" select="'http://hdl.handle.net'" as="xs:string"/> |
---|
191 | <xsl:variable name="Handle_reference" select="fn:substring-after($URI, ':')" as="xs:string"/> |
---|
192 | <xsl:variable name="Handle_HTTP_URL" select="fn:concat($HANDLE_PREFIX, '/', $Handle_reference)" as="xs:string"/> |
---|
193 | <a href="{$Handle_HTTP_URL}"><xsl:value-of select="$Handle_HTTP_URL"/></a> |
---|
194 | </xsl:when> |
---|
195 | <xsl:otherwise> |
---|
196 | <a href="{ResourceRef}"><xsl:value-of select="ResourceRef"/></a> |
---|
197 | </xsl:otherwise> |
---|
198 | </xsl:choose> |
---|
199 | </td> |
---|
200 | <td class="attributeValue"> |
---|
201 | <xsl:value-of select="ResourceType"/> |
---|
202 | </td> |
---|
203 | <td class="attributeValue"> |
---|
204 | <xsl:value-of select="ResourceType/@mimetype"/> |
---|
205 | </td> |
---|
206 | <td class="attributeValue"> |
---|
207 | <xsl:value-of select="./@id"/> |
---|
208 | </td> |
---|
209 | </tr> |
---|
210 | </xsl:for-each> |
---|
211 | </tbody> |
---|
212 | </table> |
---|
213 | </p> |
---|
214 | </xsl:if> |
---|
215 | </div> |
---|
216 | |
---|
217 | <!-- |
---|
218 | <p> |
---|
219 | <h1>Journal file proxy list</h1> |
---|
220 | <xsl:for-each select="JournalFileProxyList"> </xsl:for-each> |
---|
221 | </p> |
---|
222 | |
---|
223 | <p> |
---|
224 | <h1>Resource relations</h1> |
---|
225 | <xsl:for-each select="Resources/ResourceRelationList/ResourceRelation"> </xsl:for-each> |
---|
226 | </p> |
---|
227 | --> |
---|
228 | |
---|
229 | <p> |
---|
230 | <h1>Metadata content</h1> |
---|
231 | <xsl:call-template name="Component_tree"/> |
---|
232 | </p> |
---|
233 | |
---|
234 | <footer> |
---|
235 | <p>Created by <address class="author"> <xsl:value-of select="Header/MdCreator"/> |
---|
236 | </address> on <time datetime="{Header/MdCreationDate}"> |
---|
237 | <xsl:value-of select="Header/MdCreationDate" |
---|
238 | /></time> |
---|
239 | <br /> |
---|
240 | <small>Located at <a href="{Header/MdSelfLink}"> |
---|
241 | <xsl:value-of select="Header/MdSelfLink"/></a> |
---|
242 | </small> |
---|
243 | <br /> |
---|
244 | <small>Belongs to "<xsl:value-of select="Header/MdCollectionDisplayName" |
---|
245 | />" |
---|
246 | </small> |
---|
247 | <br /> |
---|
248 | <xsl:variable name="resource_URL" |
---|
249 | select="fn:concat('http://catalog.clarin.eu/ds/ComponentRegistry?item=',Header/MdProfile)"/> |
---|
250 | <small>Based on <a href="{$resource_URL}"><xsl:value-of select="$resource_URL"/></a> |
---|
251 | </small> |
---|
252 | </p> |
---|
253 | </footer> |
---|
254 | </article> |
---|
255 | </body> |
---|
256 | </html> |
---|
257 | |
---|
258 | </xsl:template> |
---|
259 | </xsl:stylesheet> |
---|