Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,16 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
String field = fieldIter.nextItem().getStringValue();
targetType = getType(contextSequence, field);
}
if (targetType != Type.ITEM) {
keys[i -j] = keys[i - j].convertTo(targetType);
if (targetType != Type.ITEM && !Type.subTypeOf(keys[i -j].getItemType(), targetType)) {
if (keys[i - j].hasMany()) {
final Sequence temp = new ValueSequence(keys[i -j].getItemCount());
for (final SequenceIterator iterator = keys[i - j].unorderedIterator(); iterator.hasNext(); ) {
temp.add(iterator.nextItem().convertTo(targetType));
}
keys[i - j] = temp;
} else {
keys[i - j] = keys[i - j].convertTo(targetType);
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions extensions/indexes/range/test/src/xquery/fields.xql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ declare variable $rt:COLLECTION_CONFIG :=
<field name="stage" match="tei:stage" type="xs:string"/>
<field name="head" match="tei:head" type="xs:string"/>
</create>
<create match="//tei:sp">
<field name="sp-who" match="@who" type="xs:string"/>
<field name="sp-line-n" match="tei:l/@n" type="xs:int"/>
</create>
</range>
</index>
</collection>;
Expand Down Expand Up @@ -173,4 +177,16 @@ declare
%test:assertXPath("$result//stats:index[@type = 'new-range'][@optimization = 2]")
function rt:field-head-ends-with-optimize($head as xs:string) {
count(collection($rt:COLLECTION)//tei:div[ends-with(tei:head, $head)])
};

declare
%test:assertEquals(2)
function rt:field-multi-values-lookup() {
count(collection($rt:COLLECTION)//tei:sp[@who = ("mac-first-witch.", "mac-sec.-witch.")])
};

declare
%test:assertEquals(2)
function rt:field-multi-values-lookup-int() {
count(collection($rt:COLLECTION)//tei:sp[tei:l/@n = ("1", 3)])
};