|
21 | 21 | */
|
22 | 22 | package org.exist.xquery.functions.fn;
|
23 | 23 |
|
24 |
| -import org.apache.commons.lang3.ArrayUtils; |
25 | 24 | import org.apache.commons.lang3.StringUtils;
|
26 | 25 | import org.exist.xquery.*;
|
27 | 26 | import org.exist.xquery.value.*;
|
28 | 27 | import org.w3c.dom.Node;
|
29 | 28 |
|
30 | 29 | import java.net.URI;
|
31 | 30 | import java.net.URISyntaxException;
|
| 31 | +import java.util.Set; |
32 | 32 |
|
33 | 33 | import static org.exist.xquery.FunctionDSL.optParam;
|
34 | 34 | import static org.exist.xquery.FunctionDSL.returnsOpt;
|
@@ -67,6 +67,12 @@ public class FunBaseURI extends BasicFunction {
|
67 | 67 | FS_PARAM_NODE
|
68 | 68 | );
|
69 | 69 |
|
| 70 | + // Namespace node does not exist in xquery, hence left out of array. |
| 71 | + private static final Set<Short> CANDIDATE_NODE_TYPES = Set.of( |
| 72 | + Node.DOCUMENT_NODE, Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE, Node.TEXT_NODE, |
| 73 | + Node.COMMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE |
| 74 | + ); |
| 75 | + |
70 | 76 | public FunBaseURI(XQueryContext context, FunctionSignature signature) {
|
71 | 77 | super(context, signature);
|
72 | 78 | }
|
@@ -119,13 +125,8 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
|
119 | 125 | final Node node = nodeValue.getNode();
|
120 | 126 | final short type = node.getNodeType();
|
121 | 127 |
|
122 |
| - // Namespace node does not exist in xquery, hence left out of array. |
123 |
| - final short[] quickStops = {Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE, |
124 |
| - Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, |
125 |
| - Node.DOCUMENT_NODE}; |
126 |
| - |
127 | 128 | // Quick escape
|
128 |
| - if (!ArrayUtils.contains(quickStops, type)) { |
| 129 | + if (!CANDIDATE_NODE_TYPES.contains(type)) { |
129 | 130 | return Sequence.EMPTY_SEQUENCE;
|
130 | 131 | }
|
131 | 132 |
|
|
0 commit comments