Changeset 3150
- Timestamp:
- 07/17/13 13:48:44 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk/vlo_importer/src/main/resources/cmdi2xhtml.xsl
r2846 r3150 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 2 <xsl:stylesheet 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 4 xmlns:xs="http://www.w3.org/2001/XMLSchema" 4 5 xmlns:cmd="http://www.clarin.eu/cmd/" … … 18 19 cdata-section-elements="td"/> 19 20 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"/> 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"/> 25 33 26 34 <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())"/> 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())"/> 31 45 <li> 32 46 33 47 <code class="node"> 34 <xsl:value-of select="fn:concat(local-name(), ' ')"/> 35 <xsl:if test="count(@*) > 0"> 48 <xsl:value-of 49 select="fn:concat(local-name(), ' ')"/> 50 <xsl:if 51 test="count(@*) > 0"> 36 52 <div class="attributes"> 37 <xsl:for-each select="@*"> 38 <xsl:value-of select="name()"/>="<xsl:value-of select="."/>" 53 <xsl:for-each 54 select="@*"> 55 <xsl:value-of 56 select="name()"/>="<xsl:value-of select="."/>" 39 57 </xsl:for-each> 40 58 </div> … … 43 61 44 62 <xsl:choose> 45 <xsl:when test="$nchildren = 0"> 63 <xsl:when 64 test="$nchildren = 0 and not(not(child::node()))"> 46 65 <!--<br /><br />--> 47 66 <div class="Component_tree_node_content"> 48 <xsl:variable name="leaf_value" select="self::element()" as="xs:string"/> 49 <xsl:variable name="HTTP_URL" select="starts-with($leaf_value, 'http://')" as="xs:boolean"/> 50 <code class="leaf"> 51 <xsl:choose> 52 <xsl:when test="$HTTP_URL"> 53 <a href="{$leaf_value}"><xsl:value-of select="$leaf_value"/></a> 54 </xsl:when> 55 <xsl:otherwise> 56 <xsl:value-of select="$leaf_value"/> 57 </xsl:otherwise> 58 </xsl:choose> 59 </code> 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> 60 117 </div> 61 118 </xsl:when> 62 119 <xsl:otherwise> 63 120 <ul> 64 <xsl:call-template name="Component_tree"> 65 <xsl:with-param name="nodeset" select="self::element()"/> 121 <xsl:call-template 122 name="Component_tree"> 123 <xsl:with-param 124 name="nodeset" 125 select="self::element()"/> 66 126 </xsl:call-template> 67 127 </ul> … … 75 135 </xsl:template> 76 136 77 78 137 <xsl:template match="CMD"> 138 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 139 <meta charset="utf-8"/> 140 <head> 141 <title>CMDI collection "<xsl:value-of select="./Header/MdCollectionDisplayName" xmlns="cmd"/>"</title> 142 <link rel="stylesheet" type="text/css" href="http://catalog.clarin.eu/ds/vlo/css/main.css"></link> 143 79 144 <style media="screen" type="text/css"> 80 145 <![CDATA[ … … 131 196 ]]> 132 197 </style> 198 </head> 199 <body> 133 200 <article style="background-color:#EEEEEE"> 134 201 <div class="endgame"> 135 <p> 136 <h1>Resources</h1> 137 <table> 138 <caption>Resources</caption> 139 <thead> 140 <tr> 141 <th class="attribute">Reference to resource</th> 142 <th class="attribute">Resource description</th> 143 <th class="attribute">Resource MIME type</th> 144 <th class="attribute">Resource Proxy ID</th> 145 </tr> 146 </thead> 147 <tbody class="attributesTbody"> 148 <xsl:for-each select="Resources/ResourceProxyList/ResourceProxy"> 149 <xsl:variable name="URI" select="ResourceRef/text()" as="xs:string"/> 150 <tr> 151 <td class="attributeValue"> 152 <xsl:variable name="protocol" select="fn:substring-before($URI, ':')" as="xs:string"/> 153 <xsl:choose> 154 <xsl:when test="$protocol = 'hdl'"> 155 <xsl:variable name="HANDLE_PREFIX" select="'http://hdl.handle.net'" as="xs:string"/> 156 <xsl:variable name="Handle_reference" select="fn:substring-after($URI, ':')" as="xs:string"/> 157 <xsl:variable name="Handle_HTTP_URL" select="fn:concat($HANDLE_PREFIX, '/', $Handle_reference)" as="xs:string"/> 158 <a href="{$Handle_HTTP_URL}"><xsl:value-of select="$Handle_HTTP_URL"/></a> 159 </xsl:when> 160 <xsl:otherwise> 161 <a href="{ResourceRef}"><xsl:value-of select="ResourceRef"/></a> 162 </xsl:otherwise> 163 </xsl:choose> 164 </td> 165 <td class="attributeValue"> 166 <xsl:value-of select="ResourceType"/> 167 </td> 168 <td class="attributeValue"> 169 <xsl:value-of select="ResourceType/@mimetype"/> 170 </td> 171 <td class="attributeValue"> 172 <xsl:value-of select="./@id"/> 173 </td> 174 </tr> 175 </xsl:for-each> 176 </tbody> 177 </table> 178 </p> 202 <xsl:if test="not(not(Resources/*[normalize-space()]))"> 203 <p> 204 <h1>Resources</h1> 205 <table> 206 <caption>Resources</caption> 207 <thead> 208 <tr> 209 <th class="attribute">Reference to resource</th> 210 <th class="attribute">Resource description</th> 211 <th class="attribute">Resource MIME type</th> 212 <th class="attribute">Resource Proxy ID</th> 213 </tr> 214 </thead> 215 <tbody class="attributesTbody"> 216 <xsl:for-each 217 select="Resources/ResourceProxyList/ResourceProxy"> 218 <xsl:variable 219 name="URI" 220 select="ResourceRef/text()" 221 as="xs:string"/> 222 <tr> 223 <td class="attributeValue"> 224 <xsl:variable 225 name="protocol" 226 select="fn:substring-before($URI, ':')" 227 as="xs:string"/> 228 <xsl:choose> 229 <xsl:when 230 test="$protocol = 'hdl'"> 231 <xsl:variable 232 name="HANDLE_PREFIX" 233 select="'http://hdl.handle.net'" 234 as="xs:string"/> 235 <xsl:variable 236 name="Handle_reference" 237 select="fn:substring-after($URI, ':')" 238 as="xs:string"/> 239 <xsl:variable 240 name="Handle_HTTP_URL" 241 select="fn:concat($HANDLE_PREFIX, '/', $Handle_reference)" 242 as="xs:string"/> 243 <a href="{$Handle_HTTP_URL}"> 244 <xsl:value-of 245 select="$Handle_HTTP_URL"/> 246 </a> 247 </xsl:when> 248 <xsl:otherwise> 249 <a href="{ResourceRef}"> 250 <xsl:value-of 251 select="ResourceRef"/> 252 </a> 253 </xsl:otherwise> 254 </xsl:choose> 255 </td> 256 <td class="attributeValue"> 257 <xsl:value-of select="ResourceType"/> 258 </td> 259 <td class="attributeValue"> 260 <xsl:value-of select="ResourceType/@mimetype"/> 261 </td> 262 <td class="attributeValue"> 263 <xsl:value-of select="./@id"/> 264 </td> 265 </tr> 266 </xsl:for-each> 267 </tbody> 268 </table> 269 </p> 270 </xsl:if> 179 271 </div> 180 272 … … 184 276 </p> 185 277 </article> 278 </body> 279 </html> 186 280 </xsl:template> 187 281 </xsl:stylesheet>
Note: See TracChangeset
for help on using the changeset viewer.