Use query_rewrite filter to throw error for @attr 1=12
[metaproxy-moved-to-github.git] / etc / pqf2pqf-loc.xsl
1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2   version="1.0">
3
4   <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
5
6   <!--
7 ./yaz-xmlquery -p '@and @attr 1=1016 @attr 4=2 @attr 6=3 the @attr 1=4 fish' > test.xml && xmllint -format test.xml && ./yaz-xmlquery -x test1.xml && xsltproc pqf2pqf.xsl test.xml |tee test2.xml && ./yaz-xmlquery -x test2.xml 
8
9 ./yaz-xmlquery -p '@not @attr 1=1016 @attr 4=2 @attr 6=3 @attr 7=1 @attr 8=4 fish @attr 1=4 fish' > test.xml && xmllint -format test.xml && ./yaz-xmlquery -x test.xml && xsltproc pqf2pqf.xsl test.xml |tee test2.xml && ./yaz-xmlquery -x test2.xml 
10   -->
11
12   <!-- disable default templates -->
13   <xsl:template match="text()"/>
14   <xsl:template match="node()"/>
15
16   <!-- identity stylesheet templates -->
17   <!-- these parse pqf-xml input recursively and make identity operations -->
18   <xsl:template match="/query">
19     <query>
20       <xsl:apply-templates/>
21     </query>
22   </xsl:template>
23
24   <xsl:template match="rpn">
25     <rpn>
26       <xsl:attribute name="set">
27         <xsl:value-of  select="@set"/>
28       </xsl:attribute>
29       <xsl:apply-templates/>
30     </rpn>
31   </xsl:template>
32
33   <xsl:template match="operator">
34     <operator>
35       <xsl:attribute name="type">
36         <xsl:value-of  select="@type"/>
37       </xsl:attribute>
38       <xsl:apply-templates/>
39     </operator>
40   </xsl:template>
41
42   <xsl:template match="apt">
43     <apt>
44       <xsl:apply-templates select="attr"/>
45       <xsl:apply-templates select="term"/>
46     </apt>
47   </xsl:template>
48
49   <xsl:template match="attr">
50     <xsl:copy-of select="."/>
51   </xsl:template>
52
53   <xsl:template match="term">
54     <xsl:copy-of select="."/>
55   </xsl:template>
56
57   <!-- throw diagnostic for unsupported use attributes -->
58   <xsl:template match="attr[@type=1][@value=12]">
59     <diagnostic code="114" addinfo="{@value}"/>
60   </xsl:template>
61
62 </xsl:stylesheet>
63
64