Various changes to display
[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><b><xsl:value-of select="name(.)"/>:</b></td></tr>
20         <xsl:for-each select="./*">
21           <xsl:variable name="resource" select="./@rdf:resource"/>
22           <tr>
23             <td/><td><b><xsl:value-of select="name(.)"/>:</b></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>BIBFRAME 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             <h4>
94               <xsl:text>Record </xsl:text>
95               <xsl:value-of select="srw:recordPosition"/>
96             </h4>
97             <p>
98               <xsl:if test="srw:recordPacking='string'">
99                 <pre>
100                   <xsl:value-of select="srw:recordData"/>
101                 </pre>
102               </xsl:if>
103               <xsl:if test="srw:recordPacking='xml'">
104                 <xsl:choose>
105                   <xsl:when test="srw:recordSchema='marcxml'">
106                     <xsl:text>MARCXML</xsl:text>
107                   </xsl:when>
108                   <xsl:when test="srw:recordSchema='bibframe'">
109                     <xsl:apply-templates select="srw:recordData"/>
110                   </xsl:when>
111                 </xsl:choose>
112               </xsl:if>
113
114               <form name="rawlink" method="get">
115                 <input type="hidden" name="version">
116                   <xsl:attribute name="value">
117                     <xsl:value-of
118                         select="//srw:echoedSearchRetrieveRequest/srw:version"/>
119                   </xsl:attribute>
120                 </input>
121                 <input type="hidden" name="operation" value="searchRetrieve"/>
122                 <input type="hidden" name="query">
123                   <xsl:attribute name="value">
124                     <xsl:value-of
125                         select="//srw:echoedSearchRetrieveRequest/srw:query"/>
126                   </xsl:attribute>
127                 </input>
128                 <input type="hidden" name="recordPacking">
129                   <xsl:attribute name="value">
130                     <xsl:value-of select="srw:recordPacking"/>
131                   </xsl:attribute>
132                 </input>
133                 <input type="hidden" name="recordSchema">
134                   <xsl:attribute name="value">
135                     <xsl:value-of select="srw:recordSchema"/>
136                   </xsl:attribute>
137                 </input>
138                 <input type="hidden" name="startRecord">
139                   <xsl:attribute name="value">
140                     <xsl:value-of select="srw:recordPosition"/>
141                   </xsl:attribute>
142                 </input>
143                 <input type="hidden" name="maximumRecords" value="1"/>
144                 <input type="submit">
145                   <xsl:attribute name="value">
146                     <xsl:text>Raw Record </xsl:text>
147                     <xsl:value-of select="srw:recordPosition"/>
148                   </xsl:attribute>
149                 </input>
150               </form>
151             </p>
152           </div>
153         </xsl:for-each>
154       </xsl:for-each>
155     </div>
156   </xsl:template>
157
158 </xsl:stylesheet>