Path: blob/master/test/jdk/javax/xml/jaxp/parsers/8022548/JDK8022548.xsl
41154 views
<?xml version="1.0" encoding='UTF-8'?>12<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"3version="1.0"4xmlns:my="http://www.jenitennison.com/"5xmlns="http://www.w3.org/1999/xhtml"6xmlns:html="http://www.w3.org/1999/xhtml"7xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"8xmlns:dc="http://purl.org/dc/elements/1.1/"9xmlns:dcq="http://purl.org/dc/qualifiers/1.0/"10xmlns:vcf="http://www.ietf.org/internet-drafts/draft-dawson-vcard-xml-dtd-03.txt"11xmlns:msxsl="urn:schemas-microsoft-com:xslt"12exclude-result-prefixes="rdf dc dcq my html vcf msxsl">1314<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"15cdata-section-elements="script"16indent="no"17method="xml"18encoding='UTF-8'/>1920<xsl:param name="dynamic" select="'true'" />21<xsl:param name="base" select="'/'" />2223<xsl:variable name="supports-document" select="function-available('document')" />24<xsl:variable name="supports-keys" select="function-available('key')" />2526<xsl:variable name="default-title" select='"Jeni's XML Site"' />2728<xsl:template match="my:doc">29<xsl:variable name="metadata" select="/*/rdf:RDF" />30<xsl:variable name="uri" select="$metadata/rdf:Description[1]/@about" />31<html>32<head>33<title>34<xsl:call-template name="get-metadata">35<xsl:with-param name="what" select="'title'" />36<xsl:with-param name="about" select="$uri" />37</xsl:call-template>38</title>39<xsl:call-template name="get-metadata">40<xsl:with-param name="what" select="'link'" />41<xsl:with-param name="about" select="$uri" />42</xsl:call-template>43<link rel="alternate" type="text/xml" href="{$uri}" />44<xsl:call-template name="get-metadata">45<xsl:with-param name="what" select="'rights'" />46<xsl:with-param name="about" select="$uri" />47</xsl:call-template>48</head>49<body>50<xsl:if test="$dynamic = 'false'">51<p id="xml-link">52Try the <a href="{$uri}">XML version</a> of this page.53If you have problems with it, consult the54<a href="/compatibility.html">compatibility page</a>.55</p>56</xsl:if>57<xsl:apply-templates />58<xsl:apply-templates select="." mode="colophon" />59</body>60</html>61</xsl:template>6263<xsl:template match="html:h1">64<h1>65<xsl:apply-templates />66<xsl:call-template name="insert-navigation" />67</h1>68</xsl:template>6970<xsl:template name="insert-navigation">71<xsl:variable name="metadata" select="/*/rdf:RDF" />72<xsl:variable name="uri" select="$metadata/rdf:Description[1]/@about" />73<xsl:if test="$uri != concat($base, 'index.xml')">74<span id="link-top">75<a class="img">76<xsl:attribute name="href">77<xsl:choose>78<xsl:when test="$dynamic = 'true'">/index.xml</xsl:when>7980<xsl:otherwise>/index.html</xsl:otherwise>81</xsl:choose>82</xsl:attribute>83<img src="{$base}resources/icons/top.gif" width="29" height="29" />84</a>85</span>86<span id="link-up">87<a class="img">88<xsl:attribute name="href">89<xsl:choose>90<xsl:when test="contains($uri, 'index.xml')">91<xsl:choose>92<xsl:when test="$dynamic = 'true'">../index.xml</xsl:when>93<xsl:otherwise>../index.html</xsl:otherwise>94</xsl:choose>95</xsl:when>96<xsl:otherwise>97<xsl:choose>98<xsl:when test="$dynamic = 'true'">index.xml</xsl:when>99<xsl:otherwise>index.html</xsl:otherwise>100</xsl:choose>101</xsl:otherwise>102</xsl:choose>103</xsl:attribute>104<img src="{$base}resources/icons/up.gif" width="29" height="29" />105</a>106</span>107</xsl:if>108</xsl:template>109110111<xsl:template match="rdf:RDF" />112113<xsl:template name="get-metadata">114<xsl:param name="what" />115<xsl:param name="about" select="/*/rdf:RDF/rdf:Description/@about" />116<xsl:variable name="metadata" select="/*/rdf:RDF" />117<xsl:variable name="type">118<xsl:choose>119<xsl:when test="contains($what, '::')">120<xsl:value-of select="substring-before($what, '::')" />121</xsl:when>122<xsl:otherwise><xsl:value-of select="$what" /></xsl:otherwise>123</xsl:choose>124</xsl:variable>125<xsl:variable name="mode">126<xsl:choose>127<xsl:when test="contains($what, '::')">128<xsl:value-of select="substring-after($what, '::')" />129</xsl:when>130<xsl:otherwise />131</xsl:choose>132</xsl:variable>133<xsl:apply-templates select="$metadata/rdf:Description[@about = $about or134(@aboutEachPrefix != '' and starts-with($about, @aboutEachPrefix))]/*[local-name() = $type]">135<xsl:with-param name="mode" select="$mode" />136</xsl:apply-templates>137</xsl:template>138139<xsl:template match="rdf:Description/*">140<xsl:param name="mode" />141<xsl:choose>142<xsl:when test="@rdf:resource != ''">143<xsl:call-template name="get-metadata">144<xsl:with-param name="about" select="@rdf:resource" />145<xsl:with-param name="what" select="$mode" />146</xsl:call-template>147</xsl:when>148<xsl:when test="$mode = '' and @rdf:value != ''">149<xsl:value-of select="@rdf:value" />150</xsl:when>151<xsl:when test="$mode = '' and *">152<xsl:apply-templates />153</xsl:when>154<xsl:otherwise>155<xsl:apply-templates select="." mode="get-metadata">156<xsl:with-param name="mode" select="$mode" />157</xsl:apply-templates>158</xsl:otherwise>159</xsl:choose>160</xsl:template>161162<xsl:template match="html:link" mode="get-metadata">163<link>164<xsl:copy-of select="@*" />165</link>166</xsl:template>167168<xsl:template match="dc:rights" mode="get-metadata">169<xsl:comment>170<xsl:value-of select="." />171</xsl:comment>172</xsl:template>173174<xsl:template match="dc:date" mode="get-metadata">175<xsl:param name="mode" select="''" />176<xsl:if test="$mode = @dcq:dateType">177<xsl:value-of select="@rdf:value" />178</xsl:if>179</xsl:template>180181<xsl:template match="vcf:vCard" mode="get-metadata">182<xsl:param name="mode" select="''" />183<xsl:choose>184<xsl:when test="$mode = 'mailto-link'">185<xsl:call-template name="link">186<xsl:with-param name="link">187<xsl:choose>188<xsl:when test="vcf:email[contains(@email.type, 'PREF')]">189<xsl:value-of select="vcf:email[contains(@email.type, 'PREF')]" />190</xsl:when>191<xsl:otherwise><xsl:value-of select="vcf:email[1]" /></xsl:otherwise>192</xsl:choose>193</xsl:with-param>194<xsl:with-param name="value">195<xsl:apply-templates select="vcf:n" mode="full" />196</xsl:with-param>197</xsl:call-template>198</xsl:when>199<xsl:when test="$mode = 'name'">200<xsl:apply-templates select="vcf:n" mode="full" />201</xsl:when>202<xsl:otherwise />203</xsl:choose>204</xsl:template>205206<xsl:template match="vcf:n" mode="full">207<xsl:if test="vcf:prefix">208<xsl:value-of select="vcf:prefix" /><xsl:text> </xsl:text>209</xsl:if>210<xsl:choose>211<xsl:when test="../vcf:nickname">212<xsl:value-of select="../vcf:nickname" />213</xsl:when>214<xsl:otherwise>215<xsl:value-of select="vcf:given" />216</xsl:otherwise>217</xsl:choose>218<xsl:text> </xsl:text>219<xsl:value-of select="vcf:family" />220</xsl:template>221222<xsl:template match="html:*">223<xsl:element name="{local-name()}">224<xsl:copy-of select="@*" />225<xsl:apply-templates />226</xsl:element>227</xsl:template>228229<xsl:template match="my:vars">230<dl>231<xsl:apply-templates />232</dl>233</xsl:template>234235<xsl:template match="my:var">236<dt id="{translate(my:name, ' ', '-')}">237<xsl:text/>$<xsl:value-of select="my:name" />238<xsl:choose>239<xsl:when test="my:value">240<xsl:text/> = <xsl:apply-templates select="my:value" />241</xsl:when>242<xsl:when test="my:default">243<xsl:text/> [= <xsl:apply-templates select="my:default" />]<xsl:text/>244</xsl:when>245</xsl:choose>246</dt>247<dd>248<xsl:if test="my:desc"><xsl:apply-templates select="my:desc" /></xsl:if>249<xsl:if test="my:option">250<ul>251<xsl:apply-templates select="my:option" />252</ul>253</xsl:if>254<xsl:apply-templates select="my:defn" />255</dd>256</xsl:template>257258<xsl:template match="my:option">259<li><xsl:apply-templates select="my:value" />: <xsl:apply-templates select="my:desc" /></li>260</xsl:template>261262<xsl:template match="my:value | my:default">263<xsl:choose>264<xsl:when test="@type">265<span class="{@type}">266<xsl:choose>267<xsl:when test="@type = 'string'">'<xsl:value-of select="." />'</xsl:when>268<xsl:when test="@type = 'rtf'">"<xsl:value-of select="." />"</xsl:when>269<xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>270</xsl:choose>271</span>272</xsl:when>273<xsl:otherwise>274<xsl:value-of select="." />275</xsl:otherwise>276</xsl:choose>277</xsl:template>278279<xsl:template match="my:post">280<div class="post">281<xsl:apply-templates />282</div>283</xsl:template>284285<xsl:template match="my:response">286<div class="response">287<xsl:apply-templates />288</div>289</xsl:template>290291<xsl:template match="my:question">292<div class="question">293<p>294<xsl:call-template name="insert-icon">295<xsl:with-param name="icon" select="'question'" />296<xsl:with-param name="active" select="false()" />297</xsl:call-template>298<xsl:text> </xsl:text>299<xsl:apply-templates select="*[1]/node()" />300</p>301<xsl:apply-templates select="*[position() > 1]"/>302</div>303</xsl:template>304305<xsl:template match="my:example | my:defn">306<pre>307<xsl:apply-templates />308</pre>309</xsl:template>310311<xsl:template match="my:example[parent::my:aside and ancestor::my:example]">312<xsl:choose>313<xsl:when test="$dynamic = 'true'">314<pre>315<xsl:apply-templates />316</pre>317</xsl:when>318<xsl:otherwise>319<span class="example">320<xsl:apply-templates />321</span>322</xsl:otherwise>323</xsl:choose>324</xsl:template>325326<xsl:template match="my:example[parent::my:aside and not(ancestor::my:example)]">327<xsl:call-template name="split-and-code">328<xsl:with-param name="text" select="string(.)" />329</xsl:call-template>330</xsl:template>331332<xsl:template name="split-and-code">333<xsl:param name="text" />334<br />335<xsl:choose>336<xsl:when test="contains($text, '
')">337<code><xsl:value-of select="substring-before($text, '
')" /></code>338<xsl:call-template name="split-and-code">339<xsl:with-param name="text" select="substring-after($text, '
')" />340</xsl:call-template>341</xsl:when>342<xsl:otherwise>343<code><xsl:value-of select="$text" /></code>344</xsl:otherwise>345</xsl:choose>346</xsl:template>347348<xsl:template match="my:aside">349<xsl:choose>350<xsl:when test="$dynamic = 'true'">351<span class="note"352><img src="{$base}resources/icons/note.gif" height="17" width="13" border="0"353style="z-index: 2;"354onmouseover="javascript:{generate-id()}.style.visibility='visible';"355onmouseout="javascript:{generate-id()}.style.visibility='hidden';"356/><span class="popup" id="{generate-id()}"357onmouseover="javascript:{generate-id()}.style.visibility='visible';"358onmouseout="javascript:{generate-id()}.style.visibility='hidden';">359<xsl:apply-templates />360</span361></span>362</xsl:when>363<xsl:otherwise>364<xsl:text> </xsl:text>365<span class="note">[<xsl:apply-templates />]</span>366<xsl:text> </xsl:text>367</xsl:otherwise>368</xsl:choose>369</xsl:template>370371<xsl:template match="my:quote">372<blockquote uri="{@href}">373<xsl:apply-templates />374</blockquote>375<p class="byline">376<xsl:text>[From </xsl:text>377<xsl:call-template name="link">378<xsl:with-param name="link" select="@href" />379<xsl:with-param name="value">380<xsl:value-of select="@href" />381</xsl:with-param>382</xsl:call-template>383<xsl:text>]</xsl:text>384</p>385</xsl:template>386387<xsl:template match="my:icon">388<xsl:call-template name="insert-icon">389<xsl:with-param name="icon" select="@name" />390</xsl:call-template>391</xsl:template>392393<xsl:template name="insert-icon">394<xsl:param name="icon" select="'goto'" />395<xsl:param name="active" select="true()" />396<img src="{$base}resources/icons/{$icon}.gif" height="28" width="28" border="0">397<xsl:attribute name="src">398<xsl:value-of select="$base" />399<xsl:text>resources/icons/</xsl:text>400<xsl:if test="not($active)">click-</xsl:if>401<xsl:value-of select="$icon" />402<xsl:text>.gif</xsl:text>403</xsl:attribute>404<xsl:if test="$active">405<xsl:attribute name="onmouseover">javascript:this.src='<xsl:value-of select="$base" />resources/icons/over-<xsl:value-of select="$icon" />.gif'</xsl:attribute>406<xsl:attribute name="onclick">javascript:this.src='<xsl:value-of select="$base" />resources/icons/click-<xsl:value-of select="$icon" />.gif'</xsl:attribute>407<xsl:attribute name="onmouseout">javascript:this.src='<xsl:value-of select="$base" />resources/icons/<xsl:value-of select="$icon" />.gif'</xsl:attribute>408</xsl:if>409</img>410</xsl:template>411412<xsl:template match="my:links">413<xsl:choose>414<xsl:when test="parent::html:dd">415<xsl:apply-templates select="my:link" mode="list" />416</xsl:when>417<xsl:otherwise>418<xsl:call-template name="columnise">419<xsl:with-param name="max-height" select="3" />420</xsl:call-template>421</xsl:otherwise>422</xsl:choose>423</xsl:template>424425<xsl:template name="columnise">426<xsl:param name="max-height" select="5" />427<xsl:param name="max-width" select="3" />428<xsl:variable name="no-items" select="count(*)" />429<xsl:variable name="width">430<xsl:choose>431<xsl:when test="$no-items > $max-height * $max-width">432<xsl:value-of select="$max-width" />433</xsl:when>434<xsl:otherwise>435<xsl:value-of select="ceiling($no-items div $max-height)" />436</xsl:otherwise>437</xsl:choose>438</xsl:variable>439<xsl:variable name="height" select="ceiling($no-items div $width)" />440<table>441<colgroup span="{$width}" />442<tr>443<xsl:for-each select="*[position() = 1 or position() mod $height = 1]">444<td>445<xsl:apply-templates select=". | following-sibling::*[position() < $height]" mode="list" />446</td>447</xsl:for-each>448</tr>449</table>450</xsl:template>451452<xsl:template match="my:link" mode="list">453<p class="link">454<xsl:call-template name="link">455<xsl:with-param name="link" select="@href" />456<xsl:with-param name="value">457<xsl:value-of select="." />458</xsl:with-param>459<xsl:with-param name="addicon" select="true()" />460</xsl:call-template>461</p>462</xsl:template>463464<xsl:template match="my:link">465<xsl:apply-templates select="." mode="link" />466</xsl:template>467468<xsl:template match="*[@href][. != '']" mode="link">469<xsl:call-template name="link">470<xsl:with-param name="link" select="@href" />471<xsl:with-param name="value">472<xsl:apply-templates />473</xsl:with-param>474<xsl:with-param name="addicon" select="@addicon" />475</xsl:call-template>476</xsl:template>477478<xsl:template match="*[@href][. = '']" mode="link">479<xsl:call-template name="link">480<xsl:with-param name="link" select="@href" />481<xsl:with-param name="value">482<xsl:value-of select="@href" />483</xsl:with-param>484<xsl:with-param name="addicon" select="@addicon" />485</xsl:call-template>486</xsl:template>487488<xsl:template match="text()|@*" mode="link">489<xsl:call-template name="link">490<xsl:with-param name="link" select="." />491<xsl:with-param name="value">492<xsl:value-of select="." />493</xsl:with-param>494</xsl:call-template>495</xsl:template>496497<xsl:template name="link">498<xsl:param name="link" />499<xsl:param name="value" />500<xsl:param name="addicon" select="''" />501<xsl:variable name="uri">502<xsl:call-template name="full-uri">503<xsl:with-param name="uri" select="$link" />504</xsl:call-template>505</xsl:variable>506<xsl:variable name="class">507<xsl:call-template name="uri-class">508<xsl:with-param name="uri" select="$uri" />509</xsl:call-template>510</xsl:variable>511<xsl:if test="$addicon">512<a href="{$uri}">513<xsl:attribute name="class">514<xsl:text>img </xsl:text>515<xsl:value-of select="$class" />516</xsl:attribute>517<xsl:call-template name="insert-icon">518<xsl:with-param name="icon">519<xsl:call-template name="icon-type">520<xsl:with-param name="uri" select="$uri" />521</xsl:call-template>522</xsl:with-param>523</xsl:call-template>524</a>525<xsl:text> </xsl:text>526</xsl:if>527<a href="{$uri}">528<xsl:if test="$class != ''">529<xsl:attribute name="class">530<xsl:value-of select="$class" />531</xsl:attribute>532</xsl:if>533<xsl:copy-of select="$value" />534</a>535</xsl:template>536537<xsl:template name="full-uri">538<xsl:param name="uri" />539<xsl:variable name="partial-uri">540<xsl:choose>541<xsl:when test="$dynamic='false' and542substring($uri, string-length($uri) - 3, 4) = '.xml'">543<xsl:value-of select="concat(substring($uri, 1, string-length($uri) - 4), '.html')" />544</xsl:when>545<xsl:otherwise><xsl:value-of select="$uri" /></xsl:otherwise>546</xsl:choose>547</xsl:variable>548<xsl:choose>549<xsl:when test="starts-with($partial-uri, 'www')">550<xsl:text>http://</xsl:text><xsl:value-of select="$partial-uri" />551</xsl:when>552<xsl:when test="contains($partial-uri, '@') and not(starts-with($partial-uri, 'mailto:'))">553<xsl:text>mailto:</xsl:text><xsl:value-of select="$partial-uri" />554</xsl:when>555<xsl:otherwise><xsl:value-of select="$partial-uri" /></xsl:otherwise>556</xsl:choose>557</xsl:template>558559<xsl:template name="uri-class">560<xsl:param name="uri" />561<xsl:choose>562<xsl:when test="starts-with($uri, 'http://') and not(starts-with($uri, $base))">offsite</xsl:when>563<xsl:when test="starts-with($uri, 'mailto:')">mailto</xsl:when>564<xsl:when test="starts-with($uri, '#')">local</xsl:when>565</xsl:choose>566</xsl:template>567568<xsl:template name="icon-type">569<xsl:param name="uri" />570<xsl:variable name="url">571<xsl:choose>572<xsl:when test="starts-with($uri, 'http://')"><xsl:value-of select="substring-after($uri, 'http://')" /></xsl:when>573<xsl:otherwise><xsl:value-of select="$uri" /></xsl:otherwise>574</xsl:choose>575</xsl:variable>576<xsl:choose>577<xsl:when test="(not(contains($url, '/')) and starts-with($url, 'www.')) or (contains($url, '/') and not(substring-after($url, '/')))">home</xsl:when>578<xsl:when test="contains($url, '@')">mail</xsl:when>579<xsl:otherwise>goto</xsl:otherwise>580</xsl:choose>581</xsl:template>582583<xsl:template match="/*" mode="colophon">584<xsl:variable name="metadata" select="/*/rdf:RDF" />585<xsl:variable name="uri" select="$metadata/rdf:Description[1]/@about" />586<div id="colophon">587<hr class="final" />588<p>589<xsl:apply-templates select="$uri" mode="link" />590<xsl:variable name="modified">591<xsl:call-template name="get-metadata">592<xsl:with-param name="what" select="'date::modified'" />593</xsl:call-template>594</xsl:variable>595<xsl:if test="string($modified)">596<xsl:text> last modified </xsl:text>597<xsl:copy-of select="$modified" />598</xsl:if>599<xsl:variable name="creator">600<xsl:call-template name="get-metadata">601<xsl:with-param name="what" select="'creator::vCard::mailto-link'" />602</xsl:call-template>603</xsl:variable>604<xsl:text> by </xsl:text>605<xsl:choose>606<xsl:when test="string($creator)">607<xsl:copy-of select="$creator" />608</xsl:when>609<xsl:otherwise>610<a href="mailto:[email protected]" class="mailto">Jeni Tennison</a>611</xsl:otherwise>612</xsl:choose>613</p>614</div>615</xsl:template>616617</xsl:stylesheet>618619620