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 *
1943 * License along with this library; if not, write to the Free Software
2044 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2145 */
22-
2346package org .exist .xquery ;
2447
2548import org .apache .commons .io .output .StringBuilderWriter ;
@@ -317,9 +340,10 @@ private FunctionStats[] sort() {
317340 return stats ;
318341 }
319342
320- public synchronized void toXML (MemTreeBuilder builder ) {
343+ public synchronized void toXML (final MemTreeBuilder builder ) {
321344 final AttributesImpl attrs = new AttributesImpl ();
322- builder .startElement (new QName ("calls" , XML_NAMESPACE , XML_PREFIX ), null );
345+ attrs .addAttribute ("" , "tracing-enabled" , "tracing-enabled" , "CDATA" , Boolean .toString (isEnabled ()));
346+ builder .startElement (new QName ("calls" , XML_NAMESPACE , XML_PREFIX ), attrs );
323347 for (final QueryStats stats : queries .values ()) {
324348 attrs .clear ();
325349 attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source );
@@ -333,20 +357,19 @@ public synchronized void toXML(MemTreeBuilder builder) {
333357 attrs .addAttribute ("" , "name" , "name" , "CDATA" , stats .qname .getStringValue ());
334358 attrs .addAttribute ("" , "elapsed" , "elapsed" , "CDATA" , Double .toString (stats .executionTime / 1000.0 ));
335359 attrs .addAttribute ("" , "calls" , "calls" , "CDATA" , Integer .toString (stats .callCount ));
336- if (stats .source != null )
337- {attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source );}
360+ if (stats .source != null ) {
361+ attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source );
362+ }
338363 builder .startElement (new QName ("function" , XML_NAMESPACE , XML_PREFIX ), attrs );
339364 builder .endElement ();
340365 }
341366 for (final IndexStats stats : indexStats .values ()) {
342367 attrs .clear ();
343368 attrs .addAttribute ("" , "type" , "type" , "CDATA" , stats .indexType );
344- attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source + " [" + stats .line + ":" +
345- stats .column + "]" );
369+ attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source + " [" + stats .line + ":" + stats .column + "]" );
346370 attrs .addAttribute ("" , "elapsed" , "elapsed" , "CDATA" , Double .toString (stats .executionTime / 1000.0 ));
347371 attrs .addAttribute ("" , "calls" , "calls" , "CDATA" , Integer .toString (stats .usageCount ));
348- attrs .addAttribute ("" , "optimization" , "optimization" , "CDATA" ,
349- Integer .toString (stats .mode ));
372+ attrs .addAttribute ("" , "optimization" , "optimization" , "CDATA" , Integer .toString (stats .mode ));
350373 builder .startElement (new QName ("index" , XML_NAMESPACE , XML_PREFIX ), attrs );
351374 builder .endElement ();
352375 }
0 commit comments