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.

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