Skip to content

Commit 00addd8

Browse files
alanpaxtonadamretter
authored andcommitted
[feature] Empty stuff for fn:path returns null
1 parent 12ae764 commit 00addd8

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ public class FnModule extends AbstractInternalModule {
169169
new FunctionDef(FunNumber.signatures[1], FunNumber.class),
170170
new FunctionDef(FunOneOrMore.signature, FunOneOrMore.class),
171171
new FunctionDef(FnOuterMost.FNS_OUTERMOST, FnOuterMost.class),
172+
new FunctionDef(FunPath.FS_PATH_SIGNATURES[0], FunPath.class),
173+
new FunctionDef(FunPath.FS_PATH_SIGNATURES[1], FunPath.class),
172174
new FunctionDef(FunPosition.signature, FunPosition.class),
173175
new FunctionDef(FunQName.signature, FunQName.class),
174176
new FunctionDef(FunRemove.signature, FunRemove.class),
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.exist.xquery.functions.fn;
2+
3+
import org.exist.dom.QName;
4+
import org.exist.xquery.*;
5+
import org.exist.xquery.value.*;
6+
7+
import static org.exist.xquery.FunctionDSL.functionSignature;
8+
9+
public class FunPath extends BasicFunction {
10+
11+
private static final QName FN_PATH_NAME = new QName("path", Function.BUILTIN_FUNCTION_NS);
12+
private static final String FN_PATH_DESCRIPTION =
13+
"Returns a path expression that can be used to select the supplied node " +
14+
"relative to the root of its containing document.";
15+
private static final FunctionReturnSequenceType FN_PATH_RETURN = new FunctionReturnSequenceType(
16+
Type.STRING, Cardinality.ZERO_OR_ONE, "The path expression, or any empty sequence");
17+
18+
public static final FunctionSignature[] FS_PATH_SIGNATURES = {
19+
functionSignature(FunPath.FN_PATH_NAME, FunPath.FN_PATH_DESCRIPTION, FunPath.FN_PATH_RETURN),
20+
functionSignature(FunPath.FN_PATH_NAME, FunPath.FN_PATH_DESCRIPTION, FunPath.FN_PATH_RETURN,
21+
new FunctionParameterSequenceType("node", Type.NODE, Cardinality.ZERO_OR_ONE, "The node for which to calculate a path expression"))
22+
};
23+
24+
public FunPath(final XQueryContext context, final FunctionSignature signature) {
25+
super(context, signature);
26+
}
27+
28+
@Override
29+
public Sequence eval(final Sequence[] args, final Sequence contextSequence) throws XPathException {
30+
return Sequence.EMPTY_SEQUENCE;
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(:
2+
: eXist-db Open Source Native XML Database
3+
: Copyright (C) 2001 The eXist-db Authors
4+
:
5+
6+
: http://www.exist-db.org
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; either
11+
: version 2.1 of the License, or (at your option) any later version.
12+
:
13+
: This library is distributed in the hope that it will be useful,
14+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
: Lesser General Public License for more details.
17+
:
18+
: You should have received a copy of the GNU Lesser General Public
19+
: License along with this library; if not, write to the Free Software
20+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
:)
22+
xquery version "3.1";
23+
24+
module namespace fnp="http://exist-db.org/xquery/test/function_sort";
25+
26+
declare namespace test="http://exist-db.org/xquery/xqsuite";
27+
28+
declare
29+
%test:assertEmpty
30+
function fnp:empty() {
31+
fn:path()
32+
};

0 commit comments

Comments
 (0)