Skip to content

Commit 8803d12

Browse files
committed
[bugfix] Raise error FOJS0007 on missing Fn namespace on elements passed to fn:xml-to-json
Closes eXist-db/exist#5543
1 parent f99cf01 commit 8803d12

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ private String unescapeEscapedJsonString(final String escapedJsonString) throws
276276

277277
private void checkNamespace(final String namespaceUri) throws XPathException {
278278
if (!Function.BUILTIN_FUNCTION_NS.equals(namespaceUri)) {
279-
// throw new XPathException(this, ErrorCodes.FOJS0006, "Element was in namespace: " + namespaceUri + ", but should have been in namespace: " + Function.BUILTIN_FUNCTION_NS);
280-
LOG.warn(ErrorCodes.FOJS0006.getErrorQName() + ": Element was in namespace: " + namespaceUri + ", but should have been in namespace: " + Function.BUILTIN_FUNCTION_NS);
279+
throw new XPathException(this, ErrorCodes.FOJS0006, "Element was in namespace: " + namespaceUri + ", but should have been in namespace: " + Function.BUILTIN_FUNCTION_NS);
281280
}
282281
}
283282
}

exist-core/src/test/java/org/exist/xquery/functions/fn/FunXmlToJsonTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import org.exist.test.ExistXmldbEmbeddedServer;
2424
import org.junit.ClassRule;
25-
import org.junit.Ignore;
2625
import org.junit.Test;
2726
import org.xmldb.api.base.XMLDBException;
2827

@@ -50,7 +49,6 @@ public void arrayInFnNs() throws XMLDBException {
5049
assertEquals("[\"Curly\",\"Larry\",\"Moe\"]", result);
5150
}
5251

53-
@Ignore("Enable in FunXmlToJson#checkNamespace(String) see: https://github.com/eXist-db/exist/issues/5543")
5452
@Test
5553
public void arrayOutsideFnNs() {
5654
final String query =
@@ -84,9 +82,8 @@ public void mapInFnNs() throws XMLDBException {
8482
assertEquals("{\"Fruit\":\"Apple\",\"Vegetable\":\"Carrot\"}", result);
8583
}
8684

87-
@Ignore("Enable in FunXmlToJson#checkNamespace(String) see: https://github.com/eXist-db/exist/issues/5543")
8885
@Test
89-
public void mapOutsideFnNs() throws XMLDBException {
86+
public void mapOutsideFnNs() {
9087
final String query =
9188
"fn:xml-to-json(\n" +
9289
" <map>\n" +

0 commit comments

Comments
 (0)