luke.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!--
  17. Display the luke request handler with graphs
  18. -->
  19. <xsl:stylesheet
  20. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  21. xmlns="http://www.w3.org/1999/xhtml"
  22. version="1.0"
  23. >
  24. <xsl:output
  25. method="html"
  26. encoding="UTF-8"
  27. media-type="text/html"
  28. doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  29. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  30. />
  31. <xsl:variable name="title">Solr Luke Request Handler Response</xsl:variable>
  32. <xsl:template match="/">
  33. <html xmlns="http://www.w3.org/1999/xhtml">
  34. <head>
  35. <link rel="stylesheet" type="text/css" href="solr-admin.css"/>
  36. <link rel="icon" href="favicon.ico" type="image/x-icon"/>
  37. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
  38. <title>
  39. <xsl:value-of select="$title"/>
  40. </title>
  41. <xsl:call-template name="css"/>
  42. </head>
  43. <body>
  44. <h1>
  45. <xsl:value-of select="$title"/>
  46. </h1>
  47. <div class="doc">
  48. <ul>
  49. <xsl:if test="response/lst[@name='index']">
  50. <li>
  51. <a href="#index">Index Statistics</a>
  52. </li>
  53. </xsl:if>
  54. <xsl:if test="response/lst[@name='fields']">
  55. <li>
  56. <a href="#fields">Field Statistics</a>
  57. <ul>
  58. <xsl:for-each select="response/lst[@name='fields']/lst">
  59. <li>
  60. <a href="#{@name}">
  61. <xsl:value-of select="@name"/>
  62. </a>
  63. </li>
  64. </xsl:for-each>
  65. </ul>
  66. </li>
  67. </xsl:if>
  68. <xsl:if test="response/lst[@name='doc']">
  69. <li>
  70. <a href="#doc">Document statistics</a>
  71. </li>
  72. </xsl:if>
  73. </ul>
  74. </div>
  75. <xsl:if test="response/lst[@name='index']">
  76. <h2><a name="index"/>Index Statistics</h2>
  77. <xsl:apply-templates select="response/lst[@name='index']"/>
  78. </xsl:if>
  79. <xsl:if test="response/lst[@name='fields']">
  80. <h2><a name="fields"/>Field Statistics</h2>
  81. <xsl:apply-templates select="response/lst[@name='fields']"/>
  82. </xsl:if>
  83. <xsl:if test="response/lst[@name='doc']">
  84. <h2><a name="doc"/>Document statistics</h2>
  85. <xsl:apply-templates select="response/lst[@name='doc']"/>
  86. </xsl:if>
  87. </body>
  88. </html>
  89. </xsl:template>
  90. <xsl:template match="lst">
  91. <xsl:if test="parent::lst">
  92. <tr>
  93. <td colspan="2">
  94. <div class="doc">
  95. <xsl:call-template name="list"/>
  96. </div>
  97. </td>
  98. </tr>
  99. </xsl:if>
  100. <xsl:if test="not(parent::lst)">
  101. <div class="doc">
  102. <xsl:call-template name="list"/>
  103. </div>
  104. </xsl:if>
  105. </xsl:template>
  106. <xsl:template name="list">
  107. <xsl:if test="count(child::*)>0">
  108. <table>
  109. <thead>
  110. <tr>
  111. <th colspan="2">
  112. <p>
  113. <a name="{@name}"/>
  114. </p>
  115. <xsl:value-of select="@name"/>
  116. </th>
  117. </tr>
  118. </thead>
  119. <tbody>
  120. <xsl:choose>
  121. <xsl:when
  122. test="@name='histogram'">
  123. <tr>
  124. <td colspan="2">
  125. <xsl:call-template name="histogram"/>
  126. </td>
  127. </tr>
  128. </xsl:when>
  129. <xsl:otherwise>
  130. <xsl:apply-templates/>
  131. </xsl:otherwise>
  132. </xsl:choose>
  133. </tbody>
  134. </table>
  135. </xsl:if>
  136. </xsl:template>
  137. <xsl:template name="histogram">
  138. <div class="doc">
  139. <xsl:call-template name="barchart">
  140. <xsl:with-param name="max_bar_width">50</xsl:with-param>
  141. <xsl:with-param name="iwidth">800</xsl:with-param>
  142. <xsl:with-param name="iheight">160</xsl:with-param>
  143. <xsl:with-param name="fill">blue</xsl:with-param>
  144. </xsl:call-template>
  145. </div>
  146. </xsl:template>
  147. <xsl:template name="barchart">
  148. <xsl:param name="max_bar_width"/>
  149. <xsl:param name="iwidth"/>
  150. <xsl:param name="iheight"/>
  151. <xsl:param name="fill"/>
  152. <xsl:variable name="max">
  153. <xsl:for-each select="int">
  154. <xsl:sort data-type="number" order="descending"/>
  155. <xsl:if test="position()=1">
  156. <xsl:value-of select="."/>
  157. </xsl:if>
  158. </xsl:for-each>
  159. </xsl:variable>
  160. <xsl:variable name="bars">
  161. <xsl:value-of select="count(int)"/>
  162. </xsl:variable>
  163. <xsl:variable name="bar_width">
  164. <xsl:choose>
  165. <xsl:when test="$max_bar_width &lt; ($iwidth div $bars)">
  166. <xsl:value-of select="$max_bar_width"/>
  167. </xsl:when>
  168. <xsl:otherwise>
  169. <xsl:value-of select="$iwidth div $bars"/>
  170. </xsl:otherwise>
  171. </xsl:choose>
  172. </xsl:variable>
  173. <table class="histogram">
  174. <tbody>
  175. <tr>
  176. <xsl:for-each select="int">
  177. <td>
  178. <xsl:value-of select="."/>
  179. <div class="histogram">
  180. <xsl:attribute name="style">background-color: <xsl:value-of select="$fill"/>; width: <xsl:value-of select="$bar_width"/>px; height: <xsl:value-of select="($iheight*number(.)) div $max"/>px;</xsl:attribute>
  181. </div>
  182. </td>
  183. </xsl:for-each>
  184. </tr>
  185. <tr>
  186. <xsl:for-each select="int">
  187. <td>
  188. <xsl:value-of select="@name"/>
  189. </td>
  190. </xsl:for-each>
  191. </tr>
  192. </tbody>
  193. </table>
  194. </xsl:template>
  195. <xsl:template name="keyvalue">
  196. <xsl:choose>
  197. <xsl:when test="@name">
  198. <tr>
  199. <td class="name">
  200. <xsl:value-of select="@name"/>
  201. </td>
  202. <td class="value">
  203. <xsl:value-of select="."/>
  204. </td>
  205. </tr>
  206. </xsl:when>
  207. <xsl:otherwise>
  208. <xsl:value-of select="."/>
  209. </xsl:otherwise>
  210. </xsl:choose>
  211. </xsl:template>
  212. <xsl:template match="int|bool|long|float|double|uuid|date">
  213. <xsl:call-template name="keyvalue"/>
  214. </xsl:template>
  215. <xsl:template match="arr">
  216. <tr>
  217. <td class="name">
  218. <xsl:value-of select="@name"/>
  219. </td>
  220. <td class="value">
  221. <ul>
  222. <xsl:for-each select="child::*">
  223. <li>
  224. <xsl:apply-templates/>
  225. </li>
  226. </xsl:for-each>
  227. </ul>
  228. </td>
  229. </tr>
  230. </xsl:template>
  231. <xsl:template match="str">
  232. <xsl:choose>
  233. <xsl:when test="@name='schema' or @name='index' or @name='flags'">
  234. <xsl:call-template name="schema"/>
  235. </xsl:when>
  236. <xsl:otherwise>
  237. <xsl:call-template name="keyvalue"/>
  238. </xsl:otherwise>
  239. </xsl:choose>
  240. </xsl:template>
  241. <xsl:template name="schema">
  242. <tr>
  243. <td class="name">
  244. <xsl:value-of select="@name"/>
  245. </td>
  246. <td class="value">
  247. <xsl:if test="contains(.,'unstored')">
  248. <xsl:value-of select="."/>
  249. </xsl:if>
  250. <xsl:if test="not(contains(.,'unstored'))">
  251. <xsl:call-template name="infochar2string">
  252. <xsl:with-param name="charList">
  253. <xsl:value-of select="."/>
  254. </xsl:with-param>
  255. </xsl:call-template>
  256. </xsl:if>
  257. </td>
  258. </tr>
  259. </xsl:template>
  260. <xsl:template name="infochar2string">
  261. <xsl:param name="i">1</xsl:param>
  262. <xsl:param name="charList"/>
  263. <xsl:variable name="char">
  264. <xsl:value-of select="substring($charList,$i,1)"/>
  265. </xsl:variable>
  266. <xsl:choose>
  267. <xsl:when test="$char='I'">
  268. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='I']"/> - </xsl:when>
  269. <xsl:when test="$char='T'">
  270. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='T']"/> - </xsl:when>
  271. <xsl:when test="$char='S'">
  272. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='S']"/> - </xsl:when>
  273. <xsl:when test="$char='M'">
  274. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='M']"/> - </xsl:when>
  275. <xsl:when test="$char='V'">
  276. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='V']"/> - </xsl:when>
  277. <xsl:when test="$char='o'">
  278. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='o']"/> - </xsl:when>
  279. <xsl:when test="$char='p'">
  280. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='p']"/> - </xsl:when>
  281. <xsl:when test="$char='O'">
  282. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='O']"/> - </xsl:when>
  283. <xsl:when test="$char='L'">
  284. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='L']"/> - </xsl:when>
  285. <xsl:when test="$char='B'">
  286. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='B']"/> - </xsl:when>
  287. <xsl:when test="$char='C'">
  288. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='C']"/> - </xsl:when>
  289. <xsl:when test="$char='f'">
  290. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='f']"/> - </xsl:when>
  291. <xsl:when test="$char='l'">
  292. <xsl:value-of select="/response/lst[@name='info']/lst/str[@name='l']"/> -
  293. </xsl:when>
  294. </xsl:choose>
  295. <xsl:if test="not($i>=string-length($charList))">
  296. <xsl:call-template name="infochar2string">
  297. <xsl:with-param name="i">
  298. <xsl:value-of select="$i+1"/>
  299. </xsl:with-param>
  300. <xsl:with-param name="charList">
  301. <xsl:value-of select="$charList"/>
  302. </xsl:with-param>
  303. </xsl:call-template>
  304. </xsl:if>
  305. </xsl:template>
  306. <xsl:template name="css">
  307. <style type="text/css">
  308. <![CDATA[
  309. td.name {font-style: italic; font-size:80%; }
  310. .doc { margin: 0.5em; border: solid grey 1px; }
  311. .exp { display: none; font-family: monospace; white-space: pre; }
  312. div.histogram { background: none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;}
  313. table.histogram { width: auto; vertical-align: bottom; }
  314. table.histogram td, table.histogram th { text-align: center; vertical-align: bottom; border-bottom: 1px solid #ff9933; width: auto; }
  315. ]]>
  316. </style>
  317. </xsl:template>
  318. </xsl:stylesheet>