Hi everyone,
Because XSLT files are themselves XML files, I've been intrigued by the idea
of using XSLT to improve its own stylesheets.
In the following DITA Open Toolkit enhancement:
#4123: Use some XSLT 3.0 features
https://github.com/dita-ot/dita-ot/issues/4123
I provide a stylesheet that performs a few simple substitutions to use XSLT3
features in obvious cases:
* Replace contains(@att, " keyword ") with contains-token(@att,
"keyword")
* Replace identity templates with <xsl:mode on-no-match="shallow-copy">
* Use mode="#current" where possible
The approach is limited by its use of template matches and regular
expressions. For some reason, I don't feel inclined to write an XPath grammar
parser in XSLT. But still, some low-hanging fruit can be obtained.
I thought about replacing concat() with "||", but I think I would need to wrap
all these instances in parentheses to avoid operator precedence issues.
Anyway, I thought I'd pass this along in case anyone found it interesting. If
someone thinks of additional XSLT3 features that could be targeted, let me
know and I'll look into it!
-----
Chris Papademetrious
Tech Writer, Implementation Group
(610) 628-9718 home office
(570) 460-6078 cell
|