New transformation: DADS to pz2
[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
61     <pz:record>
62       <xsl:for-each select="author/name">
63         <pz:metadata type="author">
64           <xsl:value-of select="." />
65         </pz:metadata>
66       </xsl:for-each>
67       
68       <xsl:for-each select="article/title">
69         <pz:metadata type="title">
70           <xsl:value-of select="." />
71         </pz:metadata>
72       </xsl:for-each>
73
74       <xsl:for-each select="journal/issn">
75         <pz:metadata type="issn">
76           <xsl:value-of select="." />
77         </pz:metadata>
78       </xsl:for-each>
79
80       <xsl:for-each select="journal/title">
81         <pz:metadata type="journal-title">
82           <xsl:value-of select="." />
83         </pz:metadata>
84       </xsl:for-each>
85
86       <xsl:for-each select="localInfo/systemno"> 
87         <pz:metadata type="system-control-nr">
88           <xsl:value-of select="."/>
89         </pz:metadata>
90       </xsl:for-each>
91
92       <pz:metadata type="description">
93         <xsl:value-of select="$description" />
94       </pz:metadata>
95       
96       <xsl:for-each select="ctrlT/term">
97         <pz:metadata type="subject">
98           <xsl:value-of select="." />
99         </pz:metadata>
100       </xsl:for-each>
101
102       <xsl:for-each select="tmarc:d773">
103         <pz:metadata type="citation">
104           <xsl:for-each select="*">
105             <xsl:value-of select="normalize-space(.)" />
106             <xsl:text> </xsl:text>
107           </xsl:for-each>
108         </pz:metadata>
109       </xsl:for-each>
110
111       <pz:metadata type="medium">
112         <xsl:value-of select="$vmedium" />
113       </pz:metadata>
114
115       <xsl:for-each select="article/fulltext">
116         <pz:metadata type="fulltext">
117           <xsl:value-of select="." />
118         </pz:metadata>
119       </xsl:for-each>
120
121       <!-- passthrough id data -->
122       <xsl:for-each select="pz:metadata">
123         <xsl:copy-of select="." />
124       </xsl:for-each>
125
126       <!-- other stylesheets importing this might want to define this -->
127       <xsl:call-template name="record-hook" />
128         
129     </pz:record>
130
131
132   </xsl:template>
133
134   <xsl:template match="text()" />
135
136 </xsl:stylesheet>