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