Page 1 of 1
"XPath/XQuery Builder" takes much longer than expected
Posted: Sat Sep 24, 2022 3:49 pm
by chrispitude
Hi everyone,
I noticed that
XPath/XQuery Builder takes much longer than I would expect.
As an experiment, I cloned
the Oxygen XML user guide repository, opened the userguide.xpr file, opened the UserManual.ditamap map, and compared the following operations being run on the current DITA map scope:
- Running an XPath/XQuery Builder query for //prolog took 195 seconds.
- Running a Delete element refactoring operation for prolog took 33 seconds.
Is this runtime difference expected, or is it a bug?
Re: "XPath/XQuery Builder" takes much longer than expected
Posted: Mon Sep 26, 2022 6:41 am
by Radu
Hi Chris,
My hunch about this is that the xpath/xquery builder takes the schema (DTD, XML Schema or associated RNG) information into account when executing.
For example you can search for "//@class" and it will find default class attribute values.
The XML refactoring on the other side has a pre-processing stage where it removes the schema information, then processes the resulting XML with XSLT and then adds it back. We do this mostly to avoid the XSLT processor expanding entity references or default attributes. But the side effect is that the transformation cannot match elements based on default attributes.
So I suspect the xpath builder to take more time because for each small DITA topic the schema is quite large, larger than the XML file and needs to be processed to extract attribute values. We have some schema caches that we use when "Validate and check for completeness" is used so I added an internal issue to look into using such caches also for XPath:
EXM-51396 Add schema cache when running XPath on multiple files
Regards,
Radu
Re: "XPath/XQuery Builder" takes much longer than expected
Posted: Mon Sep 26, 2022 11:47 pm
by chrispitude
Thanks Radu! Now the runtime behavior makes sense.
Conversely, I have sometimes wished that refactoring operations populated DITA @class attributes, to make it easier to write robust refactoring operations that process DITA source (matching base classes to include all specializations, sharing templates between DITA-OT plugins and Oxygen refactoring operations). But I suppose that is a topic for another post!
Re: "XPath/XQuery Builder" takes much longer than expected
Posted: Thu Oct 13, 2022 1:03 pm
by Radu
Hi,
As an update, in the released Oxygen 25.0 version the XPath in files evaluations are done with schema caching and are much faster.
Regards,
Radu
Re: "XPath/XQuery Builder" takes much longer than expected
Posted: Thu Oct 13, 2022 11:47 pm
by chrispitude
Hi Radu,
You weren't kidding - this feature is enormously faster for us now - thank you!
For the sake of others, is this improvement only for RelaxNG DITA grammars, or does it apply to DTD too?
Re: "XPath/XQuery Builder" takes much longer than expected
Posted: Fri Oct 14, 2022 6:28 am
by Radu
Hi Chris,
The speed improvement should work also for DTD based topics and maps. But RNG schemas take the longest to parse so for DTD based schemas the speed improvements may not be as large as the ones for RNG based schemas.
Regards,
Radu