You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

566 lines
18 KiB

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xlink="http://www.w3.org/1999/xlink"
  4. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5. xmlns:srw="http://www.loc.gov/zing/srw/"
  6. xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/"
  7. xmlns:srw_mods="info:srw/schema/1/mods-v3.2"
  8. xmlns:mods="http://www.loc.gov/mods/v3"
  9. xmlns:zr="http://explain.z3950.org/dtd/2.0/"
  10. exclude-result-prefixes="srw_mods mods srw" >
  11. <xsl:output method="html" indent="yes"/>
  12. <!--
  13. converts MODS v3.2 records (which are wrapped in SRW XML) to HTML
  14. modified after <http://www.loc.gov/standards/mods/mods.xsl> by Matthias Steffens <mailto:refbase@extracts.de>
  15. -->
  16. <!--
  17. TODO: - include previous/next navigation links (this will require the SRU query to be present in the SRU searchRetrieve response as extraResponseData!)
  18. - see inline comments labeled wit "TODO"
  19. -->
  20. <xsl:variable name="dictionary" select="document('locales/en/modsDictionary.xml')/dictionary"/>
  21. <xsl:variable name="explainResponse" select="document('sru.php')/srw:explainResponse/srw:record/srw:recordData/zr:explain"/>
  22. <xsl:variable name="officialDatabaseName" select="$explainResponse/zr:databaseInfo/zr:title"/>
  23. <xsl:variable name="hostInstitutionName" select="$explainResponse/zr:databaseInfo/zr:author"/>
  24. <xsl:variable name="databaseBaseURL" select="$explainResponse/zr:databaseInfo/zr:links/zr:link[@type='www']"/>
  25. <xsl:variable name="logoURL" select="$explainResponse/zr:databaseInfo/zr:links/zr:link[@type='icon']"/>
  26. <xsl:variable name="defaultNumberOfRecords" select="$explainResponse/zr:configInfo/zr:default[@type='numberOfRecords']"/>
  27. <xsl:variable name="totalNumberOfRecords" select="srw:searchRetrieveResponse/srw:numberOfRecords"/>
  28. <!--
  29. TODO: uncomment when including previous/next navigation links
  30. <xsl:variable name="startRecord" select="srw:searchRetrieveResponse/srw:records/srw:record[1]/srw:recordPosition"/>
  31. <xsl:variable name="nextStartRecord" select="srw:searchRetrieveResponse/srw:nextRecordPosition"/>
  32. <xsl:variable name="previousStartRecord">
  33. <xsl:choose>
  34. <xsl:when test="$startRecord = $totalNumberOfRecords">
  35. <xsl:value-of select="$totalNumberOfRecords - $defaultNumberOfRecords"/>
  36. </xsl:when>
  37. <xsl:otherwise>
  38. <xsl:if test="$startRecord &gt; 0">
  39. <xsl:value-of select="$startRecord - ( $nextStartRecord - $startRecord )"/>
  40. </xsl:if>
  41. </xsl:otherwise>
  42. </xsl:choose>
  43. </xsl:variable>
  44. -->
  45. <xsl:template match="srw:searchRetrieveResponse">
  46. <html>
  47. <head>
  48. <title><xsl:value-of select="$officialDatabaseName"/> -- Query Results</title>
  49. <meta http-equiv="Content-Style-Type" content="text/css"/>
  50. <link rel="stylesheet" href="css/style.css" type="text/css" title="CSS Definition"/>
  51. <style type="text/css">
  52. DIV {vertical-align:top;font-size:1em}
  53. .label {vertical-align:top}
  54. .data {vertical-align:top}
  55. .level2 {margin-left:1em}
  56. .level3 {margin-left:2em}
  57. .level4 {margin-left:3em}
  58. .level5 {margin-left:4em}
  59. .level6 {margin-left:5em}
  60. </style>
  61. </head>
  62. <body bgcolor="#FFFFFF">
  63. <!-- page header: -->
  64. <table class="pageheader" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This holds the title logo and info">
  65. <tr>
  66. <td valign="bottom" rowspan="2" align="left" width="120">
  67. <a>
  68. <xsl:attribute name="href">
  69. <!-- note that the logo should point to the URL given in '$hostInstitutionURL' but this information is currently not available in the SRU explain response -->
  70. <xsl:value-of select="$databaseBaseURL"/>
  71. </xsl:attribute>
  72. <img src="{$logoURL}" alt="Home" border="0" />
  73. </a>
  74. </td>
  75. <td>
  76. <h2><xsl:value-of select="$officialDatabaseName"/></h2>
  77. <span class="smallup">
  78. <a href="index.php" title="go to main page">Home</a><xsl:text> | </xsl:text>
  79. <a href="show.php?records=all" title="show all records in the database">Show All</a><xsl:text> | </xsl:text>
  80. <a href="simple_search.php" title="search the main fields of the database">Simple Search</a><xsl:text> | </xsl:text>
  81. <a href="advanced_search.php" title="search all fields of the database">Advanced Search</a>
  82. </span>
  83. </td>
  84. <td class="small" align="right" valign="middle"><br /></td>
  85. </tr>
  86. <tr>
  87. <xsl:choose>
  88. <!-- diagnostics: -->
  89. <xsl:when test="srw:diagnostics">
  90. <td><xsl:text>Your query caused the following error:</xsl:text></td>
  91. </xsl:when>
  92. <!-- search results: -->
  93. <xsl:otherwise>
  94. <td><xsl:value-of select="srw:records/srw:record[1]/srw:recordPosition"/>-<xsl:value-of select="srw:records/srw:record[position()=last()]/srw:recordPosition"/> of <xsl:value-of select="$totalNumberOfRecords"/> records found:</td>
  95. </xsl:otherwise>
  96. </xsl:choose>
  97. <td class="small" align="right" valign="middle"><a href="user_login.php" title="login to the database">Login</a></td>
  98. </tr>
  99. </table>
  100. <hr class="pageheader" align="center" width="95%" />
  101. <xsl:choose>
  102. <!-- diagnostics: -->
  103. <xsl:when test="srw:diagnostics">
  104. <xsl:apply-templates select="srw:diagnostics"/>
  105. </xsl:when>
  106. <!-- search results: -->
  107. <xsl:otherwise>
  108. <xsl:apply-templates select="srw:records"/>
  109. </xsl:otherwise>
  110. </xsl:choose>
  111. <!-- page footer: -->
  112. <hr class="pagefooter" align="center" width="95%" />
  113. <table class="pagefooter" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds the footer">
  114. <tr>
  115. <td class="small" width="105"><a href="index.php" title="go to main page">Home</a></td>
  116. <td class="small" align="center">
  117. <a href="sru.php" title="search the SRU web service">SRU Search</a><xsl:text> | </xsl:text>
  118. <a href="library_search.php">
  119. <xsl:attribute name="title">
  120. <xsl:text>search the library of the </xsl:text><xsl:value-of select="$hostInstitutionName"/>
  121. </xsl:attribute>
  122. <xsl:text>Library Search</xsl:text>
  123. </a><xsl:text> | </xsl:text>
  124. <a href="show.php" title="display details for a particular record by entering its database serial number">Show Record</a><xsl:text> | </xsl:text>
  125. <a href="extract.php" title="extract citations from a text and build an appropriate reference list">Extract Citations</a>
  126. </td>
  127. <td class="small" align="right" width="105"><a href="http://wiki.refbase.net/" title="display help">Help</a></td>
  128. </tr>
  129. </table>
  130. </body>
  131. </html>
  132. </xsl:template>
  133. <xsl:template match="srw:diagnostics">
  134. <xsl:apply-templates select="diag:diagnostic"/>
  135. </xsl:template>
  136. <xsl:template match="diag:diagnostic">
  137. <table class="error" align="center" border="0" cellpadding="0" cellspacing="10" width="95%">
  138. <tr>
  139. <td valign="top">
  140. <xsl:text>Error </xsl:text>
  141. <xsl:value-of select="substring(uri,23)"/>
  142. <xsl:text> : </xsl:text>
  143. <b><xsl:value-of select="message"/></b>
  144. <xsl:if test="details">
  145. <xsl:text>: </xsl:text>
  146. <xsl:value-of select="details"/>
  147. </xsl:if>
  148. </td>
  149. </tr>
  150. <tr>
  151. <td>
  152. <xsl:text>Choose how to proceed: </xsl:text>
  153. <a href="javascript:history.back()">Go back</a>
  154. <xsl:text> -OR- </xsl:text>
  155. <a href="sru.php">New SRU search</a>
  156. <xsl:text> -OR- </xsl:text>
  157. <a href="index.php"><xsl:text>Goto </xsl:text><xsl:value-of select="$officialDatabaseName"/><xsl:text> Home</xsl:text></a>
  158. </td>
  159. </tr>
  160. </table>
  161. </xsl:template>
  162. <xsl:template match="srw:records">
  163. <!--
  164. TODO: uncomment when including previous/next navigation links
  165. <table class="pagenav" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds browse links that link to the results pages of your query">
  166. <tr>
  167. <td align="center" valign="bottom">
  168. <xsl:if test="string-length($previousStartRecord)&gt;0 and $previousStartRecord &gt; 0">
  169. <a class="x-escape" href="{$databaseBaseURL}sru.php?version=1.1&amp;query=&amp;startRecord={$previousStartRecord}" rel="next">Previous records</a>
  170. </xsl:if>
  171. <xsl:if test="string-length($nextStartRecord)&gt;0">
  172. <xsl:if test="string-length($previousStartRecord)&gt;0 and $previousStartRecord &gt; 0"> | </xsl:if>
  173. <a class="x-escape" href="{$databaseBaseURL}sru.php?version=1.1&amp;query=&amp;startRecord={$nextStartRecord}" rel="next">Next records</a>
  174. </xsl:if>
  175. </td>
  176. </tr>
  177. </table>
  178. -->
  179. <xsl:apply-templates/>
  180. </xsl:template>
  181. <xsl:template match="srw:record">
  182. <!-- '<xsl:value-of select="position()"/>' shows: first record has position 2, second record has position 4, and so forth -->
  183. <xsl:if test="position() &gt; 2">
  184. <hr class="results" align="center" width="90%" />
  185. </xsl:if>
  186. <table class="results" align="center" border="0" cellpadding="0" cellspacing="7" width="90%" summary="This table holds a database record">
  187. <tr>
  188. <td colspan="2">
  189. <h4>Record number: <xsl:value-of select="srw:recordPosition"/></h4>
  190. </td>
  191. </tr>
  192. <xsl:apply-templates select="srw:recordData/mods:mods"/>
  193. </table>
  194. </xsl:template>
  195. <xsl:template match="srw:recordData/mods:mods">
  196. <xsl:choose>
  197. <xsl:when test="child::*">
  198. <tr>
  199. <td colspan="2">
  200. <b>
  201. <xsl:call-template name="longName">
  202. <xsl:with-param name="name">
  203. <xsl:value-of select="local-name()"/>
  204. </xsl:with-param>
  205. </xsl:call-template>
  206. <xsl:call-template name="attr"/>
  207. </b>
  208. </td>
  209. </tr>
  210. <xsl:apply-templates mode="level2"/>
  211. </xsl:when>
  212. <xsl:otherwise>
  213. <tr>
  214. <td width="350pt">
  215. <b>
  216. <xsl:call-template name="longName">
  217. <xsl:with-param name="name">
  218. <xsl:value-of select="local-name()"/>
  219. </xsl:with-param>
  220. </xsl:call-template>
  221. <xsl:call-template name="attr"/>
  222. </b>
  223. </td>
  224. <td>
  225. <xsl:call-template name="formatValue">
  226. <xsl:with-param name="name">
  227. <xsl:value-of select="local-name()"/>
  228. </xsl:with-param>
  229. </xsl:call-template>
  230. </td>
  231. </tr>
  232. </xsl:otherwise>
  233. </xsl:choose>
  234. </xsl:template>
  235. <xsl:template name="formatValue">
  236. <xsl:param name="name"/>
  237. <xsl:choose>
  238. <!-- DOI -->
  239. <xsl:when test="$name='identifier' and @type='doi'">
  240. <a href="http://dx.doi.org/{text()}">
  241. <xsl:value-of select="text()"/>
  242. </a>
  243. </xsl:when>
  244. <!-- ISBN -->
  245. <xsl:when test="$name='identifier' and @type='isbn'">
  246. <a href="http://isbn.nu/{text()}">
  247. <xsl:value-of select="text()"/>
  248. </a>
  249. </xsl:when>
  250. <!-- ISSN -->
  251. <xsl:when test="$name='identifier' and @type='issn'">
  252. <a href="http://journalseek.net/cgi-bin/journalseek/journalsearch.cgi?query={text()}&amp;field=allFields">
  253. <xsl:value-of select="text()"/>
  254. </a>
  255. </xsl:when>
  256. <!-- permanent refbase URL (e.g. <http://beta.refbase.net/show.php?record=12>) -->
  257. <xsl:when test="contains(text(),concat('exported from refbase (',$databaseBaseURL,'show.php?record='))">
  258. <xsl:variable name="refbaseURL" select="substring(text(),24,string-length(substring-before(substring(text(),24),'), last updated')))"/><!-- extracts the refbase URL from the notes string -->
  259. <xsl:variable name="lastUpdatedInfo" select="substring-after(text(),$refbaseURL)"/><!-- extracts the string after the refbase URL from the notes string -->
  260. <xsl:text>exported from refbase (</xsl:text>
  261. <a href="{$refbaseURL}">
  262. <xsl:text>record </xsl:text><xsl:value-of select="translate($refbaseURL,translate($refbaseURL,'0123456789',''),'')"/><!-- removes all characters except digits from string -->
  263. </a>
  264. <xsl:value-of select="$lastUpdatedInfo"/>
  265. </xsl:when>
  266. <!-- URL -->
  267. <xsl:when test="$name='url'">
  268. <a href="{text()}">
  269. <xsl:value-of select="text()"/>
  270. </a>
  271. </xsl:when>
  272. <xsl:when test="$name='identifier' and @type='uri'">
  273. <a href="{text()}">
  274. <xsl:value-of select="text()"/>
  275. </a>
  276. </xsl:when>
  277. <xsl:otherwise>
  278. <xsl:value-of select="text()"/>
  279. </xsl:otherwise>
  280. </xsl:choose>
  281. </xsl:template>
  282. <xsl:template match="*" mode="level2">
  283. <xsl:choose>
  284. <xsl:when test="child::*">
  285. <tr>
  286. <td colspan="2">
  287. <div class="level2">
  288. <xsl:call-template name="longName">
  289. <xsl:with-param name="name">
  290. <xsl:value-of select="local-name()"/>
  291. </xsl:with-param>
  292. </xsl:call-template>
  293. <xsl:call-template name="attr"/>
  294. </div>
  295. </td>
  296. </tr>
  297. <xsl:apply-templates mode="level3"/>
  298. </xsl:when>
  299. <xsl:otherwise>
  300. <tr>
  301. <td class="label">
  302. <div class="level2">
  303. <xsl:call-template name="longName">
  304. <xsl:with-param name="name">
  305. <xsl:value-of select="local-name()"/>
  306. </xsl:with-param>
  307. </xsl:call-template>
  308. <xsl:call-template name="attr"/>
  309. </div>
  310. </td>
  311. <td class="data">
  312. <xsl:call-template name="formatValue">
  313. <xsl:with-param name="name">
  314. <xsl:value-of select="local-name()"/>
  315. </xsl:with-param>
  316. </xsl:call-template>
  317. </td>
  318. </tr>
  319. </xsl:otherwise>
  320. </xsl:choose>
  321. </xsl:template>
  322. <xsl:template match="*" mode="level3">
  323. <xsl:choose>
  324. <xsl:when test="child::*">
  325. <tr>
  326. <td colspan="2">
  327. <div class="level3">
  328. <xsl:call-template name="longName">
  329. <xsl:with-param name="name">
  330. <xsl:value-of select="local-name()"/>
  331. </xsl:with-param>
  332. </xsl:call-template>
  333. <xsl:call-template name="attr"/>
  334. </div>
  335. </td>
  336. </tr>
  337. <xsl:apply-templates mode="level4"/>
  338. </xsl:when>
  339. <xsl:otherwise>
  340. <tr>
  341. <td class="label">
  342. <div class="level3">
  343. <xsl:call-template name="longName">
  344. <xsl:with-param name="name">
  345. <xsl:value-of select="local-name()"/>
  346. </xsl:with-param>
  347. </xsl:call-template>
  348. <xsl:call-template name="attr"/>
  349. </div>
  350. </td>
  351. <td class="data">
  352. <xsl:call-template name="formatValue">
  353. <xsl:with-param name="name">
  354. <xsl:value-of select="local-name()"/>
  355. </xsl:with-param>
  356. </xsl:call-template>
  357. </td>
  358. </tr>
  359. </xsl:otherwise>
  360. </xsl:choose>
  361. </xsl:template>
  362. <xsl:template match="*" mode="level4">
  363. <xsl:choose>
  364. <xsl:when test="child::*">
  365. <tr>
  366. <td colspan="2">
  367. <div class="level4">
  368. <xsl:call-template name="longName">
  369. <xsl:with-param name="name">
  370. <xsl:value-of select="local-name()"/>
  371. </xsl:with-param>
  372. </xsl:call-template>
  373. <xsl:call-template name="attr"/>
  374. </div>
  375. </td>
  376. </tr>
  377. <xsl:apply-templates mode="level5"/>
  378. </xsl:when>
  379. <xsl:otherwise>
  380. <tr>
  381. <td class="label">
  382. <div class="level4">
  383. <xsl:call-template name="longName">
  384. <xsl:with-param name="name">
  385. <xsl:value-of select="local-name()"/>
  386. </xsl:with-param>
  387. </xsl:call-template>
  388. <xsl:call-template name="attr"/>
  389. </div>
  390. </td>
  391. <td class="data">
  392. <xsl:call-template name="formatValue">
  393. <xsl:with-param name="name">
  394. <xsl:value-of select="local-name()"/>
  395. </xsl:with-param>
  396. </xsl:call-template>
  397. </td>
  398. </tr>
  399. </xsl:otherwise>
  400. </xsl:choose>
  401. </xsl:template>
  402. <xsl:template match="*" mode="level5">
  403. <xsl:choose>
  404. <xsl:when test="child::*">
  405. <tr>
  406. <td colspan="2">
  407. <div class="level5">
  408. <xsl:call-template name="longName">
  409. <xsl:with-param name="name">
  410. <xsl:value-of select="local-name()"/>
  411. </xsl:with-param>
  412. </xsl:call-template>
  413. <xsl:call-template name="attr"/>
  414. </div>
  415. </td>
  416. </tr>
  417. <xsl:apply-templates mode="level6"/>
  418. </xsl:when>
  419. <xsl:otherwise>
  420. <tr>
  421. <td class="label">
  422. <div class="level5">
  423. <xsl:call-template name="longName">
  424. <xsl:with-param name="name">
  425. <xsl:value-of select="local-name()"/>
  426. </xsl:with-param>
  427. </xsl:call-template>
  428. <xsl:call-template name="attr"/>
  429. </div>
  430. </td>
  431. <td class="data">
  432. <xsl:call-template name="formatValue">
  433. <xsl:with-param name="name">
  434. <xsl:value-of select="local-name()"/>
  435. </xsl:with-param>
  436. </xsl:call-template>
  437. </td>
  438. </tr>
  439. </xsl:otherwise>
  440. </xsl:choose>
  441. </xsl:template>
  442. <xsl:template match="*" mode="level6">
  443. <tr>
  444. <td class="label">
  445. <div class="level6">
  446. <xsl:call-template name="longName">
  447. <xsl:with-param name="name">
  448. <xsl:value-of select="local-name()"/>
  449. </xsl:with-param>
  450. </xsl:call-template>
  451. <xsl:call-template name="attr"/>
  452. </div>
  453. </td>
  454. <td class="data">
  455. <xsl:value-of select="text()"/>
  456. </td>
  457. </tr>
  458. </xsl:template>
  459. <xsl:template name="longName">
  460. <xsl:param name="name"/>
  461. <xsl:choose>
  462. <xsl:when test="$dictionary/entry[@key=$name]">
  463. <xsl:value-of select="$dictionary/entry[@key=$name]"/>
  464. </xsl:when>
  465. <xsl:otherwise>
  466. <xsl:value-of select="$name"/>
  467. </xsl:otherwise>
  468. </xsl:choose>
  469. </xsl:template>
  470. <xsl:template name="attr">
  471. <xsl:for-each select="@type|@point">:<xsl:call-template name="longName"><xsl:with-param name="name"><xsl:value-of select="."/></xsl:with-param></xsl:call-template></xsl:for-each>
  472. <xsl:if test="@authority or @edition">
  473. <xsl:for-each select="@authority">(<xsl:call-template name="longName"><xsl:with-param name="name"><xsl:value-of select="."/></xsl:with-param></xsl:call-template></xsl:for-each>
  474. <xsl:if test="@edition">Edition <xsl:value-of select="@edition"/></xsl:if>)</xsl:if>
  475. <xsl:variable name="attrStr">
  476. <xsl:for-each select="@*[local-name()!='edition' and local-name()!='type' and local-name()!='authority' and local-name()!='point']">
  477. <xsl:value-of select="local-name()"/>="<xsl:value-of select="."/>",</xsl:for-each>
  478. </xsl:variable>
  479. <xsl:variable name="nattrStr" select="normalize-space($attrStr)"/>
  480. <xsl:if test="string-length($nattrStr)">(<xsl:value-of select="substring($nattrStr,1,string-length($nattrStr)-1)"/>)</xsl:if>
  481. </xsl:template>
  482. </xsl:stylesheet>