[xsl] is it possible to simulate <xsl:import> precedence within a single stylesheet file?

Subject: [xsl] is it possible to simulate <xsl:import> precedence within a single stylesheet file?
From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Apr 2023 12:47:40 -0000
Hello XSLT friends,

Martin's XSLT fiddle site<https://xsltfiddle.liberty-development.net/> has
become one of my favorite XSLT learning and development tools. The ability to
see stylesheet results in real-time is enormously helpful in developing a
mental model both of the problem being solved and of XSLT itself.

Today I need to develop some functionality for a DITA-OT processing
stylesheet. The top-level stylesheet is a bunch of <xsl:import> imports of
lower-level files:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
  <xsl:import href="plugin:org.dita.base:xsl/preprocess/topicpullImpl.xsl"/>
  <xsl:import href="plugin:org.dita.base:xsl/preprocess/topicpull-task.xsl"/>
  <xsl:import href="plugin:org.dita.base:xsl/preprocess/topicpull-pr-d.xsl"/>
  <xsl:import
href="plugin:com.oxygenxml.pdf.css:xsl/preprocess/topicpull.xsl"/>
  <xsl:import href="plugin:com.synopsys.processing:topicpull.xsl"/>
  <xsl:import href="plugin:com.synopsys.mini-toc:topicpull-minitoc.xsl"/>
  <xsl:import href="plugin:com.synopsys.preserve.keyrefs:topicpull.xsl"/>
</xsl:stylesheet>

It would be super cool to create an XSLT stylesheet that flattens a top-level
DITA-OT stylesheet into something that can XSLT-fiddled with.

However, I am not sure how the import precedence rules described in 3.11.3
Stylesheet Import<https://www.w3.org/TR/xslt-30/#import> could be replicated
when flattening the stylesheet. The only solution I can think of is to convert
all implicit match priority values to explicit priority values (match
parsing!!), then completely linearize the whole mess to implement precedence
using ranges of priority values. And even if I wanted to do this (I don't!), I
am no longer fiddling with the original code because now everything uses
arbitrary priority values.

Is there some way to simulate import precedence (not priority) within a single
stylesheet file?

Thanks as always!

-----
Chris Papademetrious
Tech Writer, Implementation Group
(610) 628-9718 home office
(570) 460-6078 cell

Current Thread