Skip to content

Commit 25ea875

Browse files
committed
[bugfix] Show prefix of XPath standard library functions in the profiling output
1 parent b7f60af commit 25ea875

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

exist-core/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@
802802
<include>src/test/java/org/exist/IndexerTest.java</include>
803803
<include>src/test/java/org/exist/IndexerTest2.java</include>
804804
<include>src/test/java/org/exist/IndexerTest3.java</include>
805+
<include>src/main/java/org/exist/Namespaces.java</include>
805806
<include>src/main/resources-filtered/org/exist/system.properties</include>
806807
<include>src/main/java/org/exist/backup/ExportGUI.java</include>
807808
<include>src/main/java/org/exist/backup/ExportMain.java</include>
@@ -1236,6 +1237,7 @@
12361237
<exclude>src/test/java/org/exist/IndexerTest.java</exclude>
12371238
<exclude>src/test/java/org/exist/IndexerTest2.java</exclude>
12381239
<exclude>src/test/java/org/exist/IndexerTest3.java</exclude>
1240+
<exclude>src/main/java/org/exist/Namespaces.java</exclude>
12391241
<exclude>src/main/resources-filtered/org/exist/system.properties</exclude>
12401242
<exclude>src/main/java/org/exist/backup/ExportGUI.java</exclude>
12411243
<exclude>src/main/java/org/exist/backup/ExportMain.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
*
@@ -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/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+
}

0 commit comments

Comments
 (0)