9245e852ece5f9db77ea1677f4bbc6433794d48c
[mp-xquery-moved-to-github.git] / bibframe / xsl / fullDisplay.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:srw="http://www.loc.gov/zing/srw/"
4                 xmlns:sru="http://docs.oasis-open.org/ns/search-ws/sruResponse"
5                 xmlns:dc="http://www.loc.gov/zing/srw/dcschema/v1.0/"
6                 xmlns:zr="http://explain.z3950.org/dtd/2.0/"
7                 xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/"
8                 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
9                 xmlns:bf="http://bibframe.org/vocab/"
10                 version="1.0">
11
12   <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
13
14   <xsl:template match="text()"/>
15
16   <xsl:template match="rdf:RDF">
17     <table>
18       <xsl:for-each select="bf:*">
19         <tr><td><xsl:value-of select="name(.)"/></td></tr>
20         <xsl:for-each select="./*">
21           <xsl:variable name="resource" select="./@rdf:resource"/>
22           <tr>
23             <td/><td><xsl:value-of select="name(.)"/></td>
24             <td/><td>
25               <xsl:if test="$resource">
26                 <xsl:variable name="rvalue"
27                               select="//*[@rdf:about=$resource]/*[1]"/>
28                 <xsl:choose>
29                   <xsl:when test="$rvalue">
30                     <xsl:value-of select="$rvalue"/>
31                   </xsl:when>
32                   <xsl:otherwise>
33                     <xsl:value-of select="$resource"/>
34                   </xsl:otherwise>
35                 </xsl:choose>
36               </xsl:if>
37               <xsl:value-of select="."/>
38             </td>
39           </tr>
40         </xsl:for-each>
41       </xsl:for-each>
42     </table>
43   </xsl:template>
44
45   <xsl:template match="/">
46     <xsl:call-template name="html"/>
47   </xsl:template>
48
49   <xsl:template name="html">
50     <html>
51       <head>
52         <title>Full Display</title>
53         <link href="css.css" rel="stylesheet"
54               type="text/css" media="screen, all"/>
55       </head>
56       <body>
57         <div class="body">
58           <xsl:apply-templates/>
59         </div>
60       </body>
61     </html>
62   </xsl:template>
63
64   <xsl:template match="srw:searchRetrieveResponse">
65     <h2>Search Results</h2>
66     <xsl:call-template name="diagnostic"/>
67     <xsl:call-template name="displaysearch"/>
68   </xsl:template>
69
70   <xsl:template name="diagnostic">
71     <xsl:for-each select="//diag:diagnostic">
72      <div class="diagnostic">
73         <!-- <xsl:value-of select="diag:uri"/> -->
74         <xsl:text> </xsl:text>
75         <xsl:value-of select="diag:message"/>
76         <xsl:text>: </xsl:text>
77         <xsl:value-of select="diag:details"/>
78       </div>
79     </xsl:for-each>
80   </xsl:template>
81
82   <xsl:template name="displaysearch">
83     <div class="searchresults">
84       <xsl:for-each select="srw:numberOfRecords">
85         <h4>
86           <xsl:text>Number of Records: </xsl:text>
87           <xsl:value-of select="."/>
88         </h4>
89       </xsl:for-each>
90       <xsl:for-each select="srw:records">
91         <xsl:for-each select="srw:record">
92           <div class="record">
93             <p>
94               <xsl:text>Record: </xsl:text>
95               <xsl:value-of select="srw:recordPosition"/>
96               <xsl:text> : </xsl:text>
97               <xsl:value-of select="srw:recordSchema"/>
98               <xsl:text> : </xsl:text>
99               <xsl:value-of select="srw:recordPacking"/>
100             </p>
101             <p>
102               <xsl:if test="srw:recordPacking='string'">
103                 <pre>
104                   <xsl:value-of select="srw:recordData"/>
105                 </pre>
106               </xsl:if>
107               <xsl:if test="srw:recordPacking='xml'">
108                 <xsl:choose>
109                   <xsl:when test="srw:recordSchema='marcxml'">
110                     <xsl:text>MARCXML</xsl:text>
111                   </xsl:when>
112                   <xsl:when test="srw:recordSchema='bibframe'">
113                     <xsl:apply-templates select="srw:recordData"/>
114                   </xsl:when>
115                 </xsl:choose>
116               </xsl:if>
117
118               <form name="rawlink" method="get">
119                 <input type="hidden" name="version" value="1.2"/>
120                 <input type="hidden" name="operation" value="searchRetrieve"/>
121                 <input type="hidden" name="query">
122                   <xsl:attribute name="value">
123                     <xsl:value-of
124                         select="//srw:echoedSearchRetrieveRequest/srw:query"/>
125                   </xsl:attribute>
126                 </input>
127                 <input type="hidden" name="recordPacking">
128                   <xsl:attribute name="value">
129                     <xsl:value-of select="srw:recordPacking"/>
130                   </xsl:attribute>
131                 </input>
132                 <input type="hidden" name="recordSchema">
133                   <xsl:attribute name="value">
134                     <xsl:value-of select="srw:recordSchema"/>
135                   </xsl:attribute>
136                 </input>
137                 <input type="hidden" name="startRecord">
138                   <xsl:attribute name="value">
139                     <xsl:value-of select="srw:recordPosition"/>
140                   </xsl:attribute>
141                 </input>
142                 <input type="hidden" name="maximumRecords" value="1"/>
143                 <input type="submit">
144                   <xsl:attribute name="value">
145                     <xsl:text>Raw Record </xsl:text>
146                     <xsl:value-of select="srw:recordPosition"/>
147                   </xsl:attribute>
148                 </input>
149               </form>
150             </p>
151           </div>
152         </xsl:for-each>
153       </xsl:for-each>
154     </div>
155   </xsl:template>
156
157 </xsl:stylesheet>