Omit CVS Id. Update copyright year.
[idzebra-moved-to-github.git] / examples / oai-pmh / conf / explain2cqlpqftxt.xsl
1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2                 xmlns:e="http://explain.z3950.org/dtd/2.0/"
3                 version="1.0">
4   
5   <xsl:output method="text" encoding="UTF-8"/>
6   
7   <!-- disable all default text node output -->
8   <xsl:template match="text()"/>
9   
10   <!-- match zeerex xml record -->
11   <xsl:template match="e:explain">
12     <xsl:text>
13 # Propeties file to drive org.z3950.zing.cql.CQLNode's toPQF()
14 # back-end and the YAZ CQL-to-PQF converter.  This specifies the
15 # interpretation of various CQL indexes, relations, etc. in terms
16 # of Type-1 query attributes.
17 #
18 # This file is created from a valid ZeeRex Explain XML record using the 
19 # XSLT transformation 'explain2cqlpqftxt.xsl'
20 #
21 # xsltproc explain2cqlpqf.xsl explain.xml
22     </xsl:text>
23     <xsl:text>&#10;</xsl:text>
24     <xsl:text>&#10;</xsl:text>    
25     <xsl:apply-templates/>
26
27     <xsl:call-template name="static-text"/>
28
29   </xsl:template>
30   
31   <xsl:template match="e:databaseInfo">
32     <xsl:text># Title: </xsl:text><xsl:value-of select="e:title"/>
33     <xsl:text>&#10;</xsl:text>
34     <xsl:text>&#10;</xsl:text>
35   </xsl:template>
36   
37
38   <xsl:template match="e:indexInfo">
39     <xsl:variable name="set-default">
40       <xsl:value-of select="../e:configInfo/e:default[@type='contextSet']"/>
41     </xsl:variable>
42
43     <xsl:text># Set info</xsl:text>
44     <xsl:text>&#10;</xsl:text>
45
46     <xsl:if test="$set-default">
47       <xsl:text># Default set</xsl:text>
48       <xsl:text>&#10;</xsl:text>       
49        <xsl:text>set = </xsl:text>
50        <xsl:value-of select="e:set[@name = $set-default]/@identifier"/>
51        <xsl:text>&#10;</xsl:text>
52       <xsl:text>&#10;</xsl:text>       
53     </xsl:if>
54
55     <xsl:for-each select="e:set">
56       <!--
57       <xsl:text># </xsl:text>
58       <xsl:value-of select="e:title"/>
59       <xsl:text>&#10;</xsl:text>
60       -->
61       <xsl:text>set.</xsl:text><xsl:value-of select="@name"/>
62       <xsl:text> = </xsl:text><xsl:value-of select="@identifier"/>
63       <xsl:text>&#10;</xsl:text>
64     </xsl:for-each>
65     <xsl:text>&#10;</xsl:text>
66
67     <xsl:text># Index info</xsl:text>
68     <xsl:text>&#10;</xsl:text>
69     <xsl:for-each select="e:index">
70       <!--
71       <xsl:text># </xsl:text><xsl:value-of select="e:title"/>
72       <xsl:text>&#10;</xsl:text>
73       -->
74       <xsl:text>index.</xsl:text>
75       <xsl:value-of select="e:map/e:name/@set"/>
76       <xsl:text>.</xsl:text>
77       <xsl:value-of select="e:map/e:name/text()"/>
78       <xsl:text> = </xsl:text>
79       <xsl:for-each select="e:map/e:attr">
80         <xsl:value-of select="@type"/>
81         <xsl:text>=</xsl:text>
82         <xsl:value-of select="text()"/>
83         <xsl:text> </xsl:text>
84       </xsl:for-each>
85       <xsl:text>&#10;</xsl:text>
86     </xsl:for-each>
87     <xsl:text>&#10;</xsl:text>
88   </xsl:template>
89
90   <xsl:template match="e:configInfo">
91     <xsl:text># Relation info</xsl:text>
92     <xsl:text>&#10;</xsl:text>
93     <xsl:for-each select="e:supports[@type='relation']">
94       <xsl:choose>
95         <xsl:when test="text()='&lt;'">
96           <xsl:text>relation.&lt;  = 2=1</xsl:text>
97           <xsl:text>&#10;</xsl:text>
98         </xsl:when>
99         <xsl:when test="text()='le'">
100           <xsl:text>relation.le     = 2=2</xsl:text>
101           <xsl:text>&#10;</xsl:text>
102         </xsl:when>
103         <xsl:when test="text()='='">
104           <xsl:text>relation.eq  = 2=3</xsl:text>
105           <xsl:text>&#10;</xsl:text>
106         </xsl:when>
107         <xsl:when test="text()='eq'">
108           <xsl:text>relation.eq      = 2=3</xsl:text>
109           <xsl:text>&#10;</xsl:text>
110         </xsl:when>
111         <xsl:when test="text()='exact'">
112           <xsl:text>relation.exact = 2=3</xsl:text>
113           <xsl:text>&#10;</xsl:text>
114         </xsl:when>
115         <xsl:when test="text()='ge'">
116           <xsl:text>relation.ge  = 2=4</xsl:text>
117           <xsl:text>&#10;</xsl:text>
118         </xsl:when>
119         <xsl:when test="text()='&gt;'">
120           <xsl:text>relation.&gt;  = 2=5</xsl:text>
121           <xsl:text>&#10;</xsl:text>
122         </xsl:when>
123         <xsl:when test="text()='&lt;&gt;'">
124           <xsl:text>relation.&lt;&gt; = 2=6</xsl:text>
125           <xsl:text>&#10;</xsl:text>
126         </xsl:when>
127         <xsl:when test="text()='all'">
128           <xsl:text>relation.all      = 2=3</xsl:text>
129           <xsl:text>&#10;</xsl:text>
130         </xsl:when>
131         <xsl:when test="text()='any'">
132           <xsl:text>relation.any      = 2=3</xsl:text>
133           <xsl:text>&#10;</xsl:text>
134         </xsl:when>
135       </xsl:choose>
136     </xsl:for-each>
137     <xsl:text>&#10;</xsl:text>
138     <xsl:text>&#10;</xsl:text>
139
140     <xsl:text># Default Relation</xsl:text>
141     <xsl:text>&#10;</xsl:text>
142     <xsl:text>relation.scr = 2=3</xsl:text>
143     <xsl:text>&#10;</xsl:text>
144     <xsl:text>&#10;</xsl:text>
145
146     <xsl:text># RelationModifier info</xsl:text>
147     <xsl:text>&#10;</xsl:text>
148     <xsl:for-each select="e:supports[@type='relationModifier']">
149       <xsl:choose>
150         <xsl:when test="text()='relevant'">
151           <xsl:text>relationModifier.relevant = 2=102 </xsl:text>
152           <xsl:text>&#10;</xsl:text>
153         </xsl:when>
154         <xsl:when test="text()='fuzzy'">
155           <xsl:text>relationModifier.fuzzy = 2=100 </xsl:text>
156           <xsl:text>&#10;</xsl:text>
157         </xsl:when>
158         <xsl:when test="text()='stem'">
159           <xsl:text>relationModifier.stem = 2=101 </xsl:text>
160           <xsl:text>&#10;</xsl:text>
161         </xsl:when>
162         <xsl:when test="text()='phonetic'">
163           <xsl:text>relationModifier.phonetic  = 2=100 </xsl:text>
164           <xsl:text>&#10;</xsl:text>
165         </xsl:when>
166         <xsl:when test="text()='phrase'">
167           <xsl:text>relationModifier.phrase = 6=3 </xsl:text>
168           <xsl:text>&#10;</xsl:text>
169         </xsl:when>
170       </xsl:choose>
171     </xsl:for-each>
172     
173   </xsl:template>
174
175 <xsl:template name="static-text">
176     <xsl:text>
177
178 # Position attributes 
179 position.first                          = 3=1 6=1
180 position.any                            = 3=3 6=1
181 position.last                           = 3=4 6=1
182 position.firstAndLast                   = 3=3 6=3
183
184 # Structure attributes may be specified for individual relations; a
185 # default structure attribute my be specified by the pseudo-relation
186 # "*", to be used whenever a relation not listed here occurs.
187 #
188 structure.exact                         = 4=108
189 structure.all                           = 4=2
190 structure.any                           = 4=2
191 structure.*                             = 4=1
192 structure.eq                            = 4=3
193
194 # Truncation attributes used to implement CQL wildcard patterns.  The
195 # simpler forms, left, right- and both-truncation will be used for the
196 # simplest patterns, so that we produce PQF queries that conform more
197 # closely to the Bath Profile.  However, when a more complex pattern
198 # such as "foo*bar" is used, we fall back on Z39.58-style masking.
199 #
200 truncation.right                        = 5=1
201 truncation.left                         = 5=2
202 truncation.both                         = 5=3
203 truncation.none                         = 5=100
204 truncation.z3958                        = 5=104
205
206 # Finally, any additional attributes that should always be included
207 # with each term can be specified in the "always" property.
208 #
209 # always                                        = 6=1
210 # 6=1: completeness = incomplete subfield
211     </xsl:text>
212   </xsl:template>
213
214
215 </xsl:stylesheet>