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