Fix identical titles for bnodes=true MPX-9
[mp-xquery-moved-to-github.git] / bibframe / xsl / fullDisplay.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <?xml-stylesheet type="text/xsl" href="http://www.loc.gov/standards/sru/bibframe/fullDisplay.xsl"?>
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4                 xmlns:srw="http://www.loc.gov/zing/srw/"
5                 xmlns:sru="http://docs.oasis-open.org/ns/search-ws/sruResponse"
6                 xmlns:dc="http://www.loc.gov/zing/srw/dcschema/v1.0/"
7                 xmlns:zr="http://explain.z3950.org/dtd/2.0/"
8                 xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/"
9                 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
10                 xmlns:bf="http://bibframe.org/vocab/"
11                 version="1.0">
12
13   <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
14
15   <xsl:template match="text()"/>
16
17   <xsl:template match="rdf:RDF">
18                 <xsl:variable name="base" select="bf:Work[1]/@rdf:about"/>
19     <table>
20       <xsl:for-each select="bf:*">
21         <tr><td><b><xsl:value-of select="name(.)"/>:</b>
22         <xsl:variable name="n" select="@rdf:nodeID"/>
23         <xsl:if test="$n">
24           &#160;(<a name="{$n}"><xsl:value-of select="$n"/></a>)
25         </xsl:if>
26         <xsl:if test="@rdf:about and @rdf:about != $base">
27                 <xsl:variable name="bnodedid">
28                 <xsl:value-of select="substring-after(@rdf:about, $base)"/>
29         </xsl:variable>&#160;(<a name="{$bnodedid}"><xsl:value-of select="$bnodedid"/></a>)</xsl:if>    
30         </td></tr>
31         <xsl:for-each select="*">
32           <xsl:variable name="lang" select="@xml:lang"/>
33           <xsl:if test="not($lang='x-bf-hash')">
34             <xsl:variable name="resource" select="@rdf:resource"/>
35             <xsl:variable name="nodeid" select="@rdf:nodeID"/>
36             <tr>
37               <td/>
38               <td>
39                 <b><xsl:value-of select="name(.)"/>:</b>
40               </td>
41               <td/><td>
42               <xsl:choose>
43                 <xsl:when test="bf:Provider">
44                   <xsl:for-each select=".//bf:providerRole">
45                     <xsl:value-of select="."/><br/>
46                   </xsl:for-each>
47                   <xsl:for-each select=".//bf:providerName">
48                     <b>Name: </b><xsl:value-of select="."/><br/>
49                   </xsl:for-each>
50                   <xsl:for-each select=".//bf:providerPlace">
51                     <b>Place: </b><xsl:value-of select="."/><br/>
52                   </xsl:for-each>
53                   <xsl:for-each select=".//bf:providerDate">
54                     <xsl:value-of select="."/><br/>
55                   </xsl:for-each>
56                   <xsl:for-each select=".//bf:copyrightDate">
57                     <xsl:value-of select="."/><br/>
58                   </xsl:for-each>
59                 </xsl:when>
60                 <xsl:when test="$resource">
61                   <xsl:variable name="rvalue" select="//*[@rdf:about=$resource]/*[1]/text()"/>
62                   <xsl:choose>
63                         <xsl:when test="$rvalue">
64                                 <xsl:value-of select="$rvalue"/>&#160;(<a>
65                                         <xsl:attribute name="href">
66                                                 <xsl:value-of select="concat('#',substring-after($resource, $base))"/>
67                                         </xsl:attribute>
68                                         <xsl:value-of select="substring-after($resource, $base)"/></a>)</xsl:when>
69                     <xsl:otherwise>
70                       <a>
71                         <xsl:attribute name="href">
72                           <xsl:value-of select="$resource"/>
73                         </xsl:attribute>
74                         <xsl:value-of select="$resource"/>
75                       </a>
76                     </xsl:otherwise>
77                   </xsl:choose>
78                 </xsl:when>
79                 <xsl:when test="$nodeid">
80                   <xsl:variable name="rvalue"
81                                 select="../../..//*[@rdf:nodeID=$nodeid]/*[1]"/>
82                   <xsl:choose>
83                     <xsl:when test="$rvalue">
84                       <xsl:value-of select="$rvalue"/>
85                       &#160;(<a><xsl:attribute name="href">#<xsl:value-of select="$nodeid"/></xsl:attribute><xsl:value-of select="$nodeid"/>)</a>
86                     </xsl:when>
87                     <xsl:otherwise>
88                       <xsl:value-of select="$nodeid"/>
89                     </xsl:otherwise>
90                   </xsl:choose>
91                 </xsl:when>
92                 <xsl:when test="bf:Identifier">
93                   <xsl:for-each select="bf:Identifier/*">
94                     <b>
95                       <xsl:value-of
96                           select="substring-after(name(.),'bf:identifier')"/>:
97                     </b>
98                     <xsl:value-of select="."/><br/>
99                   </xsl:for-each>
100                 </xsl:when>
101                 <xsl:otherwise>
102                   <xsl:value-of select="."/>
103                 </xsl:otherwise>
104               </xsl:choose>
105             </td>
106             </tr>
107           </xsl:if>
108         </xsl:for-each>
109       </xsl:for-each>
110     </table>
111   </xsl:template>
112
113   <xsl:template match="/">
114     <xsl:call-template name="html"/>
115   </xsl:template>
116
117   <xsl:template name="html">
118     <html>
119       <head>
120         <title>BIBFRAME Full Display</title>
121         <link href="css.css" rel="stylesheet"
122               type="text/css" media="screen, all"/>
123                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
124       </head>
125       <body>
126         <div class="body">
127           <xsl:apply-templates/>
128         </div>
129       </body>
130     </html>
131   </xsl:template>
132
133   <xsl:template match="srw:searchRetrieveResponse">
134     <h2>Search Results</h2>
135     <xsl:call-template name="diagnostic"/>
136     <xsl:call-template name="displaysearch"/>
137   </xsl:template>
138
139   <xsl:template name="diagnostic">
140     <xsl:for-each select="//diag:diagnostic">
141      <div class="diagnostic">
142         <!-- <xsl:value-of select="diag:uri"/> -->
143         <xsl:text> </xsl:text>
144         <xsl:value-of select="diag:message"/>
145         <xsl:text>: </xsl:text>
146         <xsl:value-of select="diag:details"/>
147       </div>
148     </xsl:for-each>
149   </xsl:template>
150
151   <xsl:template name="displaysearch">
152     <div class="searchresults">
153       <xsl:for-each select="srw:numberOfRecords">
154         <h4>
155           <xsl:text>Number of Records: </xsl:text>
156           <xsl:value-of select="."/>
157         </h4>
158       </xsl:for-each>
159       <xsl:for-each select="srw:records">
160         <xsl:for-each select="srw:record">
161           <div class="record">
162             <h4>
163               <xsl:text>Record </xsl:text>
164               <xsl:value-of select="srw:recordPosition"/>
165             </h4>
166             <p>
167               <xsl:if test="srw:recordPacking='string'">
168                 <pre>
169                   <xsl:value-of select="srw:recordData"/>
170                 </pre>
171               </xsl:if>
172               <xsl:if test="srw:recordPacking='xml'">
173                 <xsl:choose>
174                   <xsl:when test="srw:recordSchema='marcxml'">
175                     <xsl:text>MARCXML</xsl:text>
176                   </xsl:when>
177                   <xsl:when test="srw:recordSchema='bibframe'">
178                     <xsl:apply-templates select="srw:recordData"/>
179                   </xsl:when>
180                 </xsl:choose>
181               </xsl:if>
182
183               <form name="rawlink" method="get">
184                 <input type="hidden" name="version">
185                   <xsl:attribute name="value">
186                     <xsl:value-of
187                         select="//srw:echoedSearchRetrieveRequest/srw:version"/>
188                   </xsl:attribute>
189                 </input>
190                 <input type="hidden" name="operation" value="searchRetrieve"/>
191                 <input type="hidden" name="query">
192                   <xsl:attribute name="value">
193                     <xsl:value-of
194                         select="//srw:echoedSearchRetrieveRequest/srw:query"/>
195                   </xsl:attribute>
196                 </input>
197                 <input type="hidden" name="recordPacking">
198                   <xsl:attribute name="value">
199                     <xsl:value-of select="srw:recordPacking"/>
200                   </xsl:attribute>
201                 </input>
202                 <input type="hidden" name="recordSchema">
203                   <xsl:attribute name="value">
204                     <xsl:value-of select="srw:recordSchema"/>
205                   </xsl:attribute>
206                 </input>
207                 <input type="hidden" name="startRecord">
208                   <xsl:attribute name="value">
209                     <xsl:value-of select="srw:recordPosition"/>
210                   </xsl:attribute>
211                 </input>
212                 <input type="hidden" name="maximumRecords" value="1"/>
213                 <input type="submit">
214                   <xsl:attribute name="value">
215                     <xsl:text>Raw Record </xsl:text>
216                     <xsl:value-of select="srw:recordPosition"/>
217                   </xsl:attribute>
218                 </input>
219               </form>
220             </p>
221           </div>
222         </xsl:for-each>
223       </xsl:for-each>
224     </div>
225   </xsl:template>
226
227 </xsl:stylesheet>