Make resources URLs, omit x-bf-hasable
[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>
20         <xsl:variable name="n" select="./@rdf:nodeID"/>
21         <xsl:if test="$n">
22           (<xsl:value-of select="$n"/>)
23         </xsl:if>
24         </td></tr>
25         <xsl:for-each select="./*">
26           <xsl:variable name="lang" select="./@xml:lang"/>
27           <xsl:if test="not($lang='x-bf-hashable')">
28             <xsl:variable name="resource" select="./@rdf:resource"/>
29             <xsl:variable name="nodeid" select="./@rdf:nodeID"/>
30             <tr>
31               <td/>
32               <td>
33                 <b><xsl:value-of select="name(.)"/>:</b>
34               </td>
35               <td/><td>
36               <xsl:choose>
37                 <xsl:when test="$resource">
38                   <xsl:variable name="rvalue"
39                                 select="//*[@rdf:about=$resource]/*[1]"/>
40                   <xsl:choose>
41                     <xsl:when test="$rvalue">
42                       <xsl:value-of select="$rvalue"/>
43                     </xsl:when>
44                     <xsl:otherwise>
45                       <a>
46                         <xsl:attribute name="href">
47                           <xsl:value-of select="$resource"/>
48                         </xsl:attribute>
49                         <xsl:value-of select="$resource"/>
50                       </a>
51                     </xsl:otherwise>
52                   </xsl:choose>
53                 </xsl:when>
54                 <xsl:when test="$nodeid">
55                   <xsl:variable name="rvalue"
56                                 select="//*[@rdf:nodeID=$nodeid]/*[1]"/>
57                   <xsl:choose>
58                     <xsl:when test="$rvalue">
59                       <xsl:value-of select="$rvalue"/>
60                       (<xsl:value-of select="$nodeid"/>)
61                     </xsl:when>
62                     <xsl:otherwise>
63                       <xsl:value-of select="$nodeid"/>
64                     </xsl:otherwise>
65                   </xsl:choose>
66                 </xsl:when>
67                 <xsl:when test="bf:Identifier">
68                   <xsl:value-of select="bf:Identifier/bf:identifierValue"/>
69                 </xsl:when>
70                 <xsl:otherwise>
71                   <xsl:value-of select="."/>
72                 </xsl:otherwise>
73               </xsl:choose>
74             </td>
75             </tr>
76           </xsl:if>
77         </xsl:for-each>
78       </xsl:for-each>
79     </table>
80   </xsl:template>
81
82   <xsl:template match="/">
83     <xsl:call-template name="html"/>
84   </xsl:template>
85
86   <xsl:template name="html">
87     <html>
88       <head>
89         <title>BIBFRAME Full Display</title>
90         <link href="css.css" rel="stylesheet"
91               type="text/css" media="screen, all"/>
92       </head>
93       <body>
94         <div class="body">
95           <xsl:apply-templates/>
96         </div>
97       </body>
98     </html>
99   </xsl:template>
100
101   <xsl:template match="srw:searchRetrieveResponse">
102     <h2>Search Results</h2>
103     <xsl:call-template name="diagnostic"/>
104     <xsl:call-template name="displaysearch"/>
105   </xsl:template>
106
107   <xsl:template name="diagnostic">
108     <xsl:for-each select="//diag:diagnostic">
109      <div class="diagnostic">
110         <!-- <xsl:value-of select="diag:uri"/> -->
111         <xsl:text> </xsl:text>
112         <xsl:value-of select="diag:message"/>
113         <xsl:text>: </xsl:text>
114         <xsl:value-of select="diag:details"/>
115       </div>
116     </xsl:for-each>
117   </xsl:template>
118
119   <xsl:template name="displaysearch">
120     <div class="searchresults">
121       <xsl:for-each select="srw:numberOfRecords">
122         <h4>
123           <xsl:text>Number of Records: </xsl:text>
124           <xsl:value-of select="."/>
125         </h4>
126       </xsl:for-each>
127       <xsl:for-each select="srw:records">
128         <xsl:for-each select="srw:record">
129           <div class="record">
130             <h4>
131               <xsl:text>Record </xsl:text>
132               <xsl:value-of select="srw:recordPosition"/>
133             </h4>
134             <p>
135               <xsl:if test="srw:recordPacking='string'">
136                 <pre>
137                   <xsl:value-of select="srw:recordData"/>
138                 </pre>
139               </xsl:if>
140               <xsl:if test="srw:recordPacking='xml'">
141                 <xsl:choose>
142                   <xsl:when test="srw:recordSchema='marcxml'">
143                     <xsl:text>MARCXML</xsl:text>
144                   </xsl:when>
145                   <xsl:when test="srw:recordSchema='bibframe'">
146                     <xsl:apply-templates select="srw:recordData"/>
147                   </xsl:when>
148                 </xsl:choose>
149               </xsl:if>
150
151               <form name="rawlink" method="get">
152                 <input type="hidden" name="version">
153                   <xsl:attribute name="value">
154                     <xsl:value-of
155                         select="//srw:echoedSearchRetrieveRequest/srw:version"/>
156                   </xsl:attribute>
157                 </input>
158                 <input type="hidden" name="operation" value="searchRetrieve"/>
159                 <input type="hidden" name="query">
160                   <xsl:attribute name="value">
161                     <xsl:value-of
162                         select="//srw:echoedSearchRetrieveRequest/srw:query"/>
163                   </xsl:attribute>
164                 </input>
165                 <input type="hidden" name="recordPacking">
166                   <xsl:attribute name="value">
167                     <xsl:value-of select="srw:recordPacking"/>
168                   </xsl:attribute>
169                 </input>
170                 <input type="hidden" name="recordSchema">
171                   <xsl:attribute name="value">
172                     <xsl:value-of select="srw:recordSchema"/>
173                   </xsl:attribute>
174                 </input>
175                 <input type="hidden" name="startRecord">
176                   <xsl:attribute name="value">
177                     <xsl:value-of select="srw:recordPosition"/>
178                   </xsl:attribute>
179                 </input>
180                 <input type="hidden" name="maximumRecords" value="1"/>
181                 <input type="submit">
182                   <xsl:attribute name="value">
183                     <xsl:text>Raw Record </xsl:text>
184                     <xsl:value-of select="srw:recordPosition"/>
185                   </xsl:attribute>
186                 </input>
187               </form>
188             </p>
189           </div>
190         </xsl:for-each>
191       </xsl:for-each>
192     </div>
193   </xsl:template>
194
195 </xsl:stylesheet>