Skip to content

Commit 9612bd3

Browse files
committed
[fix] do not skip empty string values
1 parent 9554da8 commit 9612bd3

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

exist-core/src/main/java/org/exist/xquery/functions/fn/FunSerialize.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ public static Sequence normalize(final Expression callingExpr, final XQueryConte
163163
// casting it to an xs:string and copy the string representation to the new sequence;"
164164
final StringValue stringRepresentation = new StringValue(callingExpr, next.getStringValue());
165165
// skip values that evaluate to an empty string
166-
if (stringRepresentation.getStringValue().isEmpty()) {
167-
continue;
168-
}
169166
temp.add(stringRepresentation);
170167
}
171168
}

exist-core/src/test/xquery/xquery3/serialize.xql

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -958,31 +958,38 @@ function ser:sequence-of-nodes() {
958958
declare
959959
%test:assertEquals("[|]")
960960
function ser:sequence-skip-empty-text-node() {
961-
fn:serialize((<a>[</a>, <a>
962-
</a>, <a>]</a>)/text(), map {"item-separator": "|"})
961+
(<a>[</a>, <a>
962+
</a>, <a>]</a>)/text()
963+
=> serialize(map {"item-separator": "|"})
963964
};
964965

966+
declare
967+
%test:assertEquals("||")
968+
function ser:sequence-dont-skip-empty-string() {
969+
serialize(("", "", ""), map {"item-separator": "|"})
970+
};
965971

966972
declare
967973
%test:assertEquals("foo")
968974
function ser:skip-empty-no-separator() {
969-
(<a>foo</a>, <b></b>)/text() => serialize(map{"item-separator": "!"})
975+
(<a>foo</a>, <b></b>)/text()
976+
=> serialize(map{"item-separator": "!"})
970977
};
971978

972979
declare
973980
%test:assertEquals("")
974981
function ser:empty-array-serializes-to-empty-string() {
975-
[] => serialize()
982+
serialize([])
976983
};
977984

978985
declare
979986
%test:assertEquals("")
980987
function ser:array-with-members-serializes-to-empty-string() {
981-
["", ()] => serialize()
988+
serialize(["", ()])
982989
};
983990

984991
declare
985-
%test:assertEquals("")
992+
%test:assertEquals("|")
986993
function ser:sequence-of-empty-arrays-serializes-to-empty-string() {
987-
([],[]) => serialize()
994+
serialize(([],[]), map{"item-separator": "|"})
988995
};

0 commit comments

Comments
 (0)