Skip to content

Commit 16d8b4f

Browse files
committed
[bugfix] Show prefix of XPath standard library functions in the profiling output
1 parent 11c45f3 commit 16d8b4f

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

exist-core/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@
752752
<include>src/test/java/org/exist/IndexerTest.java</include>
753753
<include>src/test/java/org/exist/IndexerTest2.java</include>
754754
<include>src/test/java/org/exist/IndexerTest3.java</include>
755+
<include>src/main/java/org/exist/Namespaces.java</include>
755756
<include>src/main/resources-filtered/org/exist/system.properties</include>
756757
<include>src/main/java/org/exist/backup/SystemExport.java</include>
757758
<include>src/main/java/org/exist/backup/ZipWriter.java</include>
@@ -1176,6 +1177,7 @@
11761177
<exclude>src/test/java/org/exist/IndexerTest.java</exclude>
11771178
<exclude>src/test/java/org/exist/IndexerTest2.java</exclude>
11781179
<exclude>src/test/java/org/exist/IndexerTest3.java</exclude>
1180+
<exclude>src/main/java/org/exist/Namespaces.java</exclude>
11791181
<exclude>src/main/resources-filtered/org/exist/system.properties</exclude>
11801182
<exclude>src/main/java/org/exist/backup/SystemExport.java</exclude>
11811183
<exclude>src/main/java/org/exist/backup/ZipWriter.java</exclude>

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
*
@@ -40,7 +64,8 @@ public interface Namespaces {
4064
String SCHEMA_INSTANCE_NS = XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
4165

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

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
import java.io.PrintWriter;
5959
import java.util.HashSet;
6060

61+
import static org.exist.Namespaces.XPATH_FUNCTIONS_NS;
62+
import static org.exist.Namespaces.XPATH_FUNCTIONS_PREFIX;
63+
6164
public class PerformanceStats implements BrokerPoolService {
6265

6366
public final static String RANGE_IDX_TYPE = "range";
@@ -250,7 +253,12 @@ public void recordQuery(String source, long elapsed) {
250253
}
251254
}
252255

253-
public void recordFunctionCall(QName qname, String source, long elapsed) {
256+
public void recordFunctionCall(QName qname, final String source, final long elapsed) {
257+
if (XPATH_FUNCTIONS_NS.equals(qname.getNamespaceURI()) && qname.getPrefix() == null) {
258+
// make sure that functions from the XPath/XQuery standard library are shown correctly in the output
259+
qname = new QName(qname.getLocalPart(), qname.getNamespaceURI(), XPATH_FUNCTIONS_PREFIX, qname.getNameType());
260+
}
261+
254262
final FunctionStats newStats = new FunctionStats(source, qname);
255263
final FunctionStats stats = functions.get(newStats);
256264
if (stats == null) {

0 commit comments

Comments
 (0)