Skip to content

Commit dcab3bd

Browse files
committed
[test] Add tests to check the behaviour of prefixed attributes within conditions of the Range Index config
See eXist-db/exist#5189
1 parent 54dc6e4 commit dcab3bd

File tree

2 files changed

+60
-7
lines changed

2 files changed

+60
-7
lines changed

extensions/indexes/range/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
<include>pom.xml</include>
187187
<include>src/test/resources-filtered/conf.xml</include>
188188
<include>src/test/resources/log4j2.xml</include>
189+
<include>src/test/xquery/range/conditions.xql</include>
189190
<include>src/main/java/org/exist/indexing/range/RangeIndexAnalyzer.java</include>
190191
<include>src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java</include>
191192
<include>src/main/java/org/exist/indexing/range/RangeIndexConfigElement.java</include>
@@ -203,6 +204,7 @@
203204
<exclude>pom.xml</exclude>
204205
<exclude>src/test/resources-filtered/conf.xml</exclude>
205206
<exclude>src/test/resources/log4j2.xml</exclude>
207+
<exclude>src/test/xquery/range/conditions.xql</exclude>
206208
<exclude>src/main/java/org/exist/indexing/range/RangeIndexAnalyzer.java</exclude>
207209
<exclude>src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java</exclude>
208210
<exclude>src/main/java/org/exist/indexing/range/RangeIndexConfigElement.java</exclude>

extensions/indexes/range/src/test/xquery/range/conditions.xql

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
(:
2+
: Elemental
3+
: Copyright (C) 2024, Evolved Binary Ltd
4+
:
5+
6+
: https://www.evolvedbinary.com | https://www.elemental.xyz
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; version 2.1.
11+
:
12+
: This library is distributed in the hope that it will be useful,
13+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
: Lesser General Public License for more details.
16+
:
17+
: You should have received a copy of the GNU Lesser General Public
18+
: License along with this library; if not, write to the Free Software
19+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
:
21+
: NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
: The original license header is included below.
23+
:
24+
: =====================================================================
25+
:
226
: eXist-db Open Source Native XML Database
327
: Copyright (C) 2001 The eXist-db Authors
428
:
@@ -36,7 +60,9 @@ declare namespace stats="http://exist-db.org/xquery/profiling";
3660
declare variable $ct:COLLECTION_CONFIG :=
3761
<collection xmlns="http://exist-db.org/collection-config/1.0">
3862
<index xmlns:xs="http://www.w3.org/2001/XMLSchema"
39-
xmlns:tei="http://www.tei-c.org/ns/1.0">
63+
xmlns:tei="http://www.tei-c.org/ns/1.0"
64+
xmlns:other1="http://other1"
65+
xmlns:other2="http://other2">
4066
<range>
4167
<create qname="tei:note">
4268
<condition attribute="type" value="availability" />
@@ -59,6 +85,14 @@ declare variable $ct:COLLECTION_CONFIG :=
5985
<field name="orig_place" match="tei:place/tei:placeName" type="xs:string" case="no"></field>
6086
</create>
6187
<create qname="tei:note" type="xs:string" case="no" />
88+
<create qname="tei:note">
89+
<condition attribute="other1:type" value="other1" />
90+
<field name="other1" type="xs:string" case="no"/>
91+
</create>
92+
<create qname="tei:note">
93+
<condition attribute="other2:type" value="other2" />
94+
<field name="other2" type="xs:string" case="no"/>
95+
</create>
6296
<create qname="tei:placeName">
6397
<condition attribute="type" value="someType" />
6498
<condition attribute="cert" value="high" />
@@ -134,7 +168,7 @@ declare variable $ct:COLLECTION_CONFIG :=
134168

135169

136170
declare variable $ct:DATA :=
137-
<TEI xmlns="http://www.tei-c.org/ns/1.0">
171+
<TEI xmlns="http://www.tei-c.org/ns/1.0" xmlns:other1="http://other1" xmlns:other2="http://other2">
138172
<teiHeader>
139173
<fileDesc>
140174
<titleStmt><title>conditional fields!</title></titleStmt>
@@ -143,7 +177,7 @@ declare variable $ct:DATA :=
143177
<msDesc>
144178
<msContents>
145179
<msItemStruct>
146-
<note type="availability">publiziert</note>
180+
<note type="availability" other1:type="other1">publiziert</note>
147181
<note type="text_type">literarisch</note>
148182
<note type="orig_place">
149183
<place>
@@ -161,10 +195,10 @@ declare variable $ct:DATA :=
161195
<placeName cert="high" type="someOtherType">Alexandria</placeName>
162196
</place>
163197
</note>
164-
<note type="start_end">startswithendswith</note>
165-
<note>foo</note>
166-
<note type="bar">foo</note>
167-
<note type="something">literarisch</note>
198+
<note type="start_end" other1:type="other1" other2:type="other2">startswithendswith</note>
199+
<note type="other2" other1:type="start_end">foo</note>
200+
<note type="bar" other2:type="other2">foo</note>
201+
<note type="something" other2:type="other2">literarisch</note>
168202
</msItemStruct>
169203
</msContents>
170204
</msDesc>
@@ -533,3 +567,20 @@ function ct:optimize-matches-no-case() {
533567
collection($ct:COLLECTION)//tei:p[matches(@type, "bb")][. = "something"]
534568
};
535569

570+
(:~
571+
: See: https://github.com/eXist-db/exist/issues/5189
572+
:)
573+
declare
574+
%test:assertEquals("publiziert", "startswithendswith")
575+
function ct:other1-index-keys() {
576+
range:index-keys-for-field("other1", function($k, $n) { $k }, 10)
577+
};
578+
579+
(:~
580+
: See: https://github.com/eXist-db/exist/issues/5189
581+
:)
582+
declare
583+
%test:assertEquals("foo", "literarisch", "startswithendswith")
584+
function ct:other2-index-keys() {
585+
range:index-keys-for-field("other2", function($k, $n) { $k }, 10)
586+
};

0 commit comments

Comments
 (0)