1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
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
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
12 <!-- disable default templates -->
13 <xsl:template match="text()"/>
14 <xsl:template match="node()"/>
16 <!-- identity stylesheet templates -->
17 <!-- these parse pqf-xml input recursively and make identity operations -->
18 <xsl:template match="/query">
20 <xsl:apply-templates/>
24 <xsl:template match="rpn">
26 <xsl:attribute name="set">
27 <xsl:value-of select="@set"/>
29 <xsl:apply-templates/>
33 <xsl:template match="operator">
35 <xsl:attribute name="type">
36 <xsl:value-of select="@type"/>
38 <xsl:apply-templates/>
42 <xsl:template match="apt">
44 <xsl:apply-templates select="attr"/>
45 <xsl:apply-templates select="term"/>
49 <xsl:template match="attr">
50 <xsl:copy-of select="."/>
53 <xsl:template match="term">
54 <xsl:copy-of select="."/>
57 <!-- validate use attributes -->
58 <xsl:template match="attr[@type=1]">
60 <xsl:when test="@value >= 1 and @value <= 11">
61 <xsl:copy-of select="."/>
63 <xsl:when test="@value >= 13 and @value <= 1010">
64 <xsl:copy-of select="."/>
66 <xsl:when test="@value >= 1013 and @value <= 1023">
67 <xsl:copy-of select="."/>
69 <xsl:when test="@value >= 1025 and @value <= 1030">
70 <xsl:copy-of select="."/>
73 <diagnostic code="114" addinfo="{@value}"/>
78 <!-- validate relation attributes -->
79 <xsl:template match="attr[@type=2]">
81 <xsl:when test="@value >= 1 and @value <= 6">
82 <xsl:copy-of select="."/>
85 <diagnostic code="117" addinfo="{@value}"/>
90 <!-- validate position attributes -->
91 <xsl:template match="attr[@type=3]">
93 <xsl:when test="@value >= 1 and @value <= 3">
94 <xsl:copy-of select="."/>
97 <diagnostic code="119" addinfo="{@value}"/>
102 <!-- validate structure attributes -->
103 <xsl:template match="attr[@type=4]">
105 <xsl:when test="@value >= 1 and @value <= 6">
106 <xsl:copy-of select="."/>
109 <diagnostic code="118" addinfo="{@value}"/>
114 <!-- validate truncation attributes -->
115 <xsl:template match="attr[@type=5]">
117 <xsl:when test="@value = 1 or @value = 100">
118 <xsl:copy-of select="."/>
121 <diagnostic code="120" addinfo="{@value}"/>
126 <!-- validate completeness attributes -->
127 <xsl:template match="attr[@type=6]">
129 <xsl:when test="@value >= 1 and @value <= 3">
130 <xsl:copy-of select="."/>
133 <diagnostic code="122" addinfo="{@value}"/>
138 <!-- throw error for other types -->
139 <xsl:template match="attr[@type >= 7]">
140 <diagnostic code="113" addinfo="{@type}"/>