Fix Last minute change
[pazpar2-moved-to-github.git] / test / dads-pz2.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
4   xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
5   xmlns:zs="http://www.loc.gov/zing/srw/"
6   xmlns:tmarc="http://www.indexdata.com/turbomarc">
7
8   <xsl:output indent="yes" method="xml" version="1.0"
9     encoding="UTF-8" />
10   <xsl:param name="medium"/>
11
12   <!-- Extract metadata from MARC21/USMARC from streamlined marcxml format 
13     http://www.loc.gov/marc/bibliographic/ecbdhome.html -->
14   <xsl:template name="record-hook" />
15
16
17   <xsl:template match="/">
18       <xsl:apply-templates />
19   </xsl:template>
20
21   <xsl:template match="zs:searchRetrieveResponse">
22       <xsl:apply-templates />
23   </xsl:template>
24
25   <xsl:template match="zs:records">
26     <collection>
27       <xsl:apply-templates />
28     </collection>
29   </xsl:template>
30
31   <xsl:template match="zs:record">
32       <xsl:apply-templates />
33   </xsl:template>  
34
35   <xsl:template match="zs:recordData">
36       <xsl:apply-templates />
37   </xsl:template>
38
39   <xsl:template match="doc">
40     <collection>
41       <xsl:apply-templates />
42     </collection>
43   </xsl:template>
44
45   <xsl:template match="art">
46     <xsl:variable name="journal_title" select="journal/title" />
47     <xsl:variable name="journal_issn" select="journal/issn" />
48     <xsl:variable name="date" select="localInfo/cdate" />
49     <xsl:variable name="description" select="abstract/abstract" />
50
51     <xsl:variable name="vmedium">
52       <xsl:choose>
53         <xsl:when test="$journal_title">article</xsl:when>
54         <xsl:otherwise>
55           <xsl:text>other</xsl:text>
56         </xsl:otherwise>
57       </xsl:choose>
58     </xsl:variable>
59     
60     <pz:record>
61       <xsl:for-each select="author/name">
62         <pz:metadata type="author">
63           <xsl:value-of select="." />
64         </pz:metadata>
65       </xsl:for-each>
66       
67       <xsl:for-each select="article/title">
68         <pz:metadata type="title">
69           <xsl:value-of select="." />
70         </pz:metadata>
71       </xsl:for-each>
72
73       <xsl:for-each select="journal/issn">
74         <pz:metadata type="issn">
75           <xsl:value-of select="." />
76         </pz:metadata>
77       </xsl:for-each>
78
79       <xsl:for-each select="journal/title">
80         <pz:metadata type="journal-title">
81           <xsl:value-of select="." />
82         </pz:metadata>
83       </xsl:for-each>
84       
85     <xsl:for-each select="journal"> 
86         <pz:metadata type="journal-subpart">
87             <xsl:text>Vol. </xsl:text><xsl:value-of select="vol" />
88             <xsl:text> no. </xsl:text><xsl:value-of select="issue" />
89             <xsl:text>(</xsl:text><xsl:value-of select="month" /><xsl:text>-</xsl:text><xsl:value-of select="year" /><xsl:text>)</xsl:text>
90             <xsl:text> p. </xsl:text><xsl:value-of select="page" />
91         </pz:metadata>
92     </xsl:for-each>      
93
94       <xsl:for-each select="localInfo/systemno"> 
95         <pz:metadata type="system-control-nr">
96           <xsl:value-of select="."/>
97         </pz:metadata>
98       </xsl:for-each>
99
100       <pz:metadata type="description">
101         <xsl:value-of select="$description" />
102       </pz:metadata>
103       
104       <xsl:for-each select="ctrlT/term">
105         <pz:metadata type="subject">
106           <xsl:value-of select="." />
107         </pz:metadata>
108       </xsl:for-each>
109
110       <xsl:for-each select="tmarc:d773">
111         <pz:metadata type="citation">
112           <xsl:for-each select="*">
113             <xsl:value-of select="normalize-space(.)" />
114             <xsl:text> </xsl:text>
115           </xsl:for-each>
116         </pz:metadata>
117       </xsl:for-each>
118
119       <pz:metadata type="medium">
120         <xsl:value-of select="$vmedium" />
121       </pz:metadata>
122
123       <xsl:for-each select="article/fulltext">
124         <pz:metadata type="fulltext">
125           <xsl:value-of select="." />
126         </pz:metadata>
127       </xsl:for-each>
128
129       <!-- passthrough id data -->
130       <xsl:for-each select="pz:metadata">
131         <xsl:copy-of select="." />
132       </xsl:for-each>
133
134       <!-- other stylesheets importing this might want to define this -->
135       <xsl:call-template name="record-hook" />
136         
137     </pz:record>
138
139
140   </xsl:template>
141
142   <xsl:template match="text()" />
143
144 </xsl:stylesheet>