Skip to content

Commit 24dab38

Browse files
authored
Merge pull request #84 from evolvedbinary/7.x.x/hotfix/profiling-fots-prefix
[7.x.x] Show prefix of XPath standard library functions in the profiling output
2 parents 45ce528 + 25ea875 commit 24dab38

File tree

104 files changed

+2640
-216
lines changed

Some content is hidden

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

104 files changed

+2640
-216
lines changed

exist-core/pom.xml

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

exist-core/src/main/java/org/exist/Namespaces.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
*
@@ -41,7 +65,8 @@ public interface Namespaces {
4165
String SCHEMA_INSTANCE_NS = XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
4266

4367
// Move this here from Function.BUILTIN_FUNCTION_NS? /ljo
44-
String XPATH_FUNCTIONS_NS = "http://www.w3.org/2005/xpath-functions";
68+
String XPATH_FUNCTIONS_NS = "http://www.w3.org/2005/xpath-functions";
69+
String XPATH_FUNCTIONS_PREFIX = "fn";
4570
String XQUERY_LOCAL_NS = "http://www.w3.org/2005/xquery-local-functions";
4671
String XPATH_DATATYPES_NS = "http://www.w3.org/2003/05/xpath-datatypes";
4772

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/PerformanceStatsImpl.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
import java.util.Map;
6363
import java.util.Set;
6464

65+
import static org.exist.Namespaces.XPATH_FUNCTIONS_NS;
66+
import static org.exist.Namespaces.XPATH_FUNCTIONS_PREFIX;
67+
6568
/**
6669
* Implementation of a PerformanceStats that is designed
6770
* to be used from a single XQuery via its {@link XQueryContext}
@@ -271,11 +274,16 @@ public void recordQuery(final String source, final long elapsed) {
271274
}
272275

273276
@Override
274-
public void recordFunctionCall(final QName qname, final String source, final long elapsed) {
277+
public void recordFunctionCall(QName qname, final String source, final long elapsed) {
275278
if (!isEnabled()) {
276279
return;
277280
}
278281

282+
if (XPATH_FUNCTIONS_NS.equals(qname.getNamespaceURI()) && qname.getPrefix() == null) {
283+
// make sure that functions from the XPath/XQuery standard library are shown correctly in the output
284+
qname = new QName(qname.getLocalPart(), qname.getNamespaceURI(), XPATH_FUNCTIONS_PREFIX, qname.getNameType());
285+
}
286+
279287
final FunctionStats newStats = new FunctionStats(source, qname);
280288
final FunctionStats stats = functions.get(newStats);
281289
if (stats == null) {
@@ -437,4 +445,4 @@ public void reset() {
437445
indexStats.clear();
438446
optimizations.clear();
439447
}
440-
}
448+
}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public class XQueryContext implements BinaryValueManager, Context {
320320

321321
protected String moduleLoadPath = ".";
322322

323-
private String defaultFunctionNamespace = Function.BUILTIN_FUNCTION_NS;
323+
private String defaultFunctionNamespace = Namespaces.XPATH_FUNCTIONS_NS;
324324
private AnyURIValue defaultElementNamespace = AnyURIValue.EMPTY_URI;
325325
private AnyURIValue defaultElementNamespaceSchema = AnyURIValue.EMPTY_URI;
326326

@@ -441,8 +441,9 @@ public class XQueryContext implements BinaryValueManager, Context {
441441
* is executing, or null if there is no
442442
* HTTP context.
443443
*/
444-
private @Nullable HttpContext httpContext = null;
445-
private static final QName UNNAMED_DECIMAL_FORMAT = new QName("__UNNAMED__", Function.BUILTIN_FUNCTION_NS);
444+
@Nullable
445+
private HttpContext httpContext = null;
446+
private static final QName UNNAMED_DECIMAL_FORMAT = new QName("__UNNAMED__", Namespaces.XPATH_FUNCTIONS_NS);
446447

447448
private final Map<QName, DecimalFormat> staticDecimalFormats = hashMap(Tuple(UNNAMED_DECIMAL_FORMAT, DecimalFormat.UNNAMED));
448449

@@ -1046,11 +1047,8 @@ public String getDefaultFunctionNamespace() {
10461047
@Override
10471048
public void setDefaultFunctionNamespace(final String uri) throws XPathException {
10481049
//Not sure for the 2nd clause : eXist-db forces the function NS as default.
1049-
if (defaultFunctionNamespace != null
1050-
&& !defaultFunctionNamespace.equals(Function.BUILTIN_FUNCTION_NS)
1051-
&& !defaultFunctionNamespace.equals(uri)) {
1052-
throw new XPathException(rootExpression, ErrorCodes.XQST0066,
1053-
"Default function namespace is already set to: '" + defaultFunctionNamespace + "'");
1050+
if ((defaultFunctionNamespace != null) && !defaultFunctionNamespace.equals(Namespaces.XPATH_FUNCTIONS_NS) && !defaultFunctionNamespace.equals(uri)) {
1051+
throw new XPathException(rootExpression, ErrorCodes.XQST0066, "Default function namespace is already set to: '" + defaultFunctionNamespace + "'");
10541052
}
10551053
defaultFunctionNamespace = uri;
10561054
}

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
*
@@ -51,7 +75,7 @@ public class ExtCollection extends BasicFunction {
5175

5276
private static final String FS_COLLECTION_NAME = "collection";
5377
static final FunctionSignature[] FS_COLLECTION = functionSignatures(
54-
new QName(FS_COLLECTION_NAME, Function.BUILTIN_FUNCTION_NS),
78+
new QName(FS_COLLECTION_NAME, FnModule.NAMESPACE_URI),
5579
"Returns the documents contained in the Collection specified in the input sequence. "
5680
+ XMLDBModule.COLLECTION_URI + " Documents contained in sub-collections are also included. "
5781
+ "If no value is supplied, the statically know documents are used; for the REST Server this could be the collection in the URI path.",

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
*
@@ -30,7 +54,7 @@
3054
public class FnDefaultLanguage extends BasicFunction {
3155

3256
public static final FunctionSignature FS_DEFAULT_LANGUAGE = FunctionDSL.functionSignature(
33-
new QName("default-language", Function.BUILTIN_FUNCTION_NS),
57+
new QName("default-language", FnModule.NAMESPACE_URI),
3458
"Returns the xs:language that is " +
3559
"the value of the default language property from the dynamic context " +
3660
"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,

0 commit comments

Comments
 (0)