Skip to content

Commit 11c45f3

Browse files
committed
[refactor] Cleanup use of XPath standard library namespace
1 parent 8b40358 commit 11c45f3

File tree

101 files changed

+2566
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2566
-201
lines changed

exist-core/pom.xml

Lines changed: 185 additions & 1 deletion
Large diffs are not rendered by default.

exist-core/src/main/java/org/exist/xquery/Function.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
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; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -55,10 +79,6 @@
5579
*/
5680
public abstract class Function extends PathExpr {
5781

58-
// Declare it in Namespaces instead? /ljo
59-
public final static String BUILTIN_FUNCTION_NS =
60-
"http://www.w3.org/2005/xpath-functions";
61-
6282
/**
6383
* The module that declared the function.
6484
*/

exist-core/src/main/java/org/exist/xquery/NamedFunctionReference.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
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; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -25,6 +49,7 @@
2549
import java.util.List;
2650

2751
import org.exist.dom.QName;
52+
import org.exist.xquery.functions.fn.FnModule;
2853
import org.exist.xquery.parser.XQueryAST;
2954
import org.exist.xquery.util.ExpressionDumper;
3055
import org.exist.xquery.value.FunctionReference;
@@ -53,7 +78,7 @@ public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
5378
}
5479

5580
public static FunctionCall lookupFunction(Expression self, XQueryContext context, QName funcName, int arity) throws XPathException {
56-
if (Function.BUILTIN_FUNCTION_NS.equals(funcName.getNamespaceURI())
81+
if (FnModule.NAMESPACE_URI.equals(funcName.getNamespaceURI())
5782
&& "concat".equals(funcName.getLocalPart())
5883
&& arity < 2) {
5984
throw new XPathException(self, ErrorCodes.XPST0017, "No such function; fn:concat requires at least two arguments");

exist-core/src/main/java/org/exist/xquery/XQueryContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public class XQueryContext implements BinaryValueManager, Context {
310310

311311
protected String moduleLoadPath = ".";
312312

313-
private String defaultFunctionNamespace = Function.BUILTIN_FUNCTION_NS;
313+
private String defaultFunctionNamespace = Namespaces.XPATH_FUNCTIONS_NS;
314314
private AnyURIValue defaultElementNamespace = AnyURIValue.EMPTY_URI;
315315
private AnyURIValue defaultElementNamespaceSchema = AnyURIValue.EMPTY_URI;
316316

@@ -444,7 +444,7 @@ public class XQueryContext implements BinaryValueManager, Context {
444444
*/
445445
@Nullable
446446
private HttpContext httpContext = null;
447-
private static final QName UNNAMED_DECIMAL_FORMAT = new QName("__UNNAMED__", Function.BUILTIN_FUNCTION_NS);
447+
private static final QName UNNAMED_DECIMAL_FORMAT = new QName("__UNNAMED__", Namespaces.XPATH_FUNCTIONS_NS);
448448

449449
private final Map<QName, DecimalFormat> staticDecimalFormats = HashMap(Tuple(UNNAMED_DECIMAL_FORMAT, DecimalFormat.UNNAMED));
450450

@@ -1063,7 +1063,7 @@ public String getDefaultFunctionNamespace() {
10631063
@Override
10641064
public void setDefaultFunctionNamespace(final String uri) throws XPathException {
10651065
//Not sure for the 2nd clause : eXist-db forces the function NS as default.
1066-
if ((defaultFunctionNamespace != null) && !defaultFunctionNamespace.equals(Function.BUILTIN_FUNCTION_NS) && !defaultFunctionNamespace.equals(uri)) {
1066+
if ((defaultFunctionNamespace != null) && !defaultFunctionNamespace.equals(Namespaces.XPATH_FUNCTIONS_NS) && !defaultFunctionNamespace.equals(uri)) {
10671067
throw new XPathException(rootExpression, ErrorCodes.XQST0066, "Default function namespace is already set to: '" + defaultFunctionNamespace + "'");
10681068
}
10691069
defaultFunctionNamespace = uri;

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
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; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -54,7 +78,7 @@ public class ExtCollection extends Function {
5478

5579
public final static FunctionSignature signature =
5680
new FunctionSignature(
57-
new QName("collection", Function.BUILTIN_FUNCTION_NS),
81+
new QName("collection", FnModule.NAMESPACE_URI),
5882
"Returns the documents contained in the collections specified in " +
5983
"the input sequence. " + XMLDBModule.COLLECTION_URI +
6084
" Documents contained in sub-collections are also included. If no value is supplied, the statically know documents are used, for the REST Server this could be the addressed collection.",

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
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; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -32,7 +56,7 @@
3256
public class FnDefaultLanguage extends BasicFunction {
3357

3458
public static final FunctionSignature FS_DEFAULT_LANGUAGE = FunctionDSL.functionSignature(
35-
new QName("default-language", Function.BUILTIN_FUNCTION_NS),
59+
new QName("default-language", FnModule.NAMESPACE_URI),
3660
"Returns the xs:language that is " +
3761
"the value of the default language property from the dynamic context " +
3862
"during the evaluation of a query or transformation in which " +

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
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; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -69,7 +93,7 @@ public class FnFormatDates extends BasicFunction {
6993

7094

7195
public final static FunctionSignature FNS_FORMAT_DATETIME_2 = new FunctionSignature(
72-
new QName("format-dateTime", Function.BUILTIN_FUNCTION_NS),
96+
new QName("format-dateTime", FnModule.NAMESPACE_URI),
7397
"Returns a string containing an xs:date value formatted for display.",
7498
new SequenceType[] {
7599
DATETIME,
@@ -79,7 +103,7 @@ public class FnFormatDates extends BasicFunction {
79103
);
80104

81105
public final static FunctionSignature FNS_FORMAT_DATETIME_5 = new FunctionSignature(
82-
new QName("format-dateTime", Function.BUILTIN_FUNCTION_NS),
106+
new QName("format-dateTime", FnModule.NAMESPACE_URI),
83107
"Returns a string containing an xs:date value formatted for display.",
84108
new SequenceType[] {
85109
DATETIME,
@@ -92,7 +116,7 @@ public class FnFormatDates extends BasicFunction {
92116
);
93117

94118
public final static FunctionSignature FNS_FORMAT_DATE_2 = new FunctionSignature(
95-
new QName("format-date", Function.BUILTIN_FUNCTION_NS),
119+
new QName("format-date", FnModule.NAMESPACE_URI),
96120
"Returns a string containing an xs:date value formatted for display.",
97121
new SequenceType[] {
98122
DATE,
@@ -102,7 +126,7 @@ public class FnFormatDates extends BasicFunction {
102126
);
103127

104128
public final static FunctionSignature FNS_FORMAT_DATE_5 = new FunctionSignature(
105-
new QName("format-date", Function.BUILTIN_FUNCTION_NS),
129+
new QName("format-date", FnModule.NAMESPACE_URI),
106130
"Returns a string containing an xs:date value formatted for display.",
107131
new SequenceType[] {
108132
DATE,
@@ -115,7 +139,7 @@ public class FnFormatDates extends BasicFunction {
115139
);
116140

117141
public final static FunctionSignature FNS_FORMAT_TIME_2 = new FunctionSignature(
118-
new QName("format-time", Function.BUILTIN_FUNCTION_NS),
142+
new QName("format-time", FnModule.NAMESPACE_URI),
119143
"Returns a string containing an xs:time value formatted for display.",
120144
new SequenceType[] {
121145
TIME,
@@ -125,7 +149,7 @@ public class FnFormatDates extends BasicFunction {
125149
);
126150

127151
public final static FunctionSignature FNS_FORMAT_TIME_5 = new FunctionSignature(
128-
new QName("format-time", Function.BUILTIN_FUNCTION_NS),
152+
new QName("format-time", FnModule.NAMESPACE_URI),
129153
"Returns a string containing an xs:time value formatted for display.",
130154
new SequenceType[] {
131155
TIME,

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
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; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -29,7 +53,7 @@
2953

3054
public class FnHasChildren extends Function {
3155

32-
private final static QName QN_HAS_CHILDREN = new QName("has-children", Function.BUILTIN_FUNCTION_NS);
56+
private final static QName QN_HAS_CHILDREN = new QName("has-children", FnModule.NAMESPACE_URI);
3357

3458
public final static FunctionSignature FNS_HAS_CHILDREN_0 = new FunctionSignature(
3559
QN_HAS_CHILDREN,

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
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; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -35,7 +59,7 @@
3559
public class FnInnerMost extends BasicFunction {
3660

3761
public final static FunctionSignature FNS_INNERMOST = new FunctionSignature(
38-
new QName("innermost", Function.BUILTIN_FUNCTION_NS),
62+
new QName("innermost", FnModule.NAMESPACE_URI),
3963
"Returns every node within the input sequence that is not an ancestor of another member of the input sequence; the nodes are returned in document order with duplicates eliminated.",
4064
new SequenceType[] {
4165
new FunctionParameterSequenceType("nodes", Type.NODE, Cardinality.ZERO_OR_MORE, "The nodes to test")

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.List;
5050
import java.util.Map;
5151

52+
import org.exist.Namespaces;
5253
import org.exist.dom.QName;
5354
import org.exist.xquery.*;
5455
import org.exist.xquery.value.FunctionParameterSequenceType;
@@ -63,6 +64,7 @@
6364
*/
6465
public class FnModule extends AbstractInternalModule {
6566

67+
public static final String NAMESPACE_URI = Namespaces.XPATH_FUNCTIONS_NS;
6668
public final static String PREFIX = "";
6769
public final static String INCLUSION_DATE = "2004-01-29";
6870
public final static String RELEASED_IN_VERSION = "pre eXist-1.0";
@@ -318,7 +320,7 @@ public String getDescription() {
318320

319321
@Override
320322
public String getNamespaceURI() {
321-
return Function.BUILTIN_FUNCTION_NS;
323+
return NAMESPACE_URI;
322324
}
323325

324326
@Override
@@ -333,13 +335,13 @@ public String getReleaseVersion() {
333335

334336
static FunctionSignature functionSignature(final String name, final String description,
335337
final FunctionReturnSequenceType returnType, final FunctionParameterSequenceType... paramTypes) {
336-
return FunctionDSL.functionSignature(new QName(name, Function.BUILTIN_FUNCTION_NS), description,
338+
return FunctionDSL.functionSignature(new QName(name, FnModule.NAMESPACE_URI), description,
337339
returnType, paramTypes);
338340
}
339341

340342
static FunctionSignature[] functionSignatures(final String name, final String description,
341343
final FunctionReturnSequenceType returnType, final FunctionParameterSequenceType[][] variableParamTypes) {
342-
return FunctionDSL.functionSignatures(new QName(name, Function.BUILTIN_FUNCTION_NS), description,
344+
return FunctionDSL.functionSignatures(new QName(name, FnModule.NAMESPACE_URI), description,
343345
returnType, variableParamTypes);
344346
}
345347
}

0 commit comments

Comments
 (0)