Hi Martin,
Thanks for trying the SEF experiment! It sounds like I would lose the ability
to interactively fiddle with the code, which would defeat the purpose of my
exercise. Still, I learned something new today!
Hi Michael,
Thatbs pretty cool how Saxon constructs the global sorted list of templates.
I think the hard part for me to emulate this is parsing the match expressions
in XSLT to compute implicit priority values. But then I thought perhaps the
<xsl:import> precedence might not actually matter much for plugin development,
since (1) later overrides earlier for the same priority, and (2) I typically
specify an explicit higher priority when I override something in the base
processing. So, I decided to punt on precedence emulation now and see what the
next hurdle to fiddling with DiTA-OT processing is.
I wrote a simple stylesheet to inline imported/included XSLT files:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform
exclude-result-prefixes="#all" version="3.0">
<!-- apply multiple processing modes ("inline", "flatten") -->
<xsl:template match="/">
<xsl:variable name="result" as="document-node()" select="."/>
<xsl:variable name="result" as="document-node()">
<xsl:apply-templates select="$result" mode="inline"/>
</xsl:variable>
<xsl:variable name="result" as="document-node()">
<xsl:apply-templates select="$result" mode="flatten"/>
</xsl:variable>
<xsl:sequence select="$result"/>
</xsl:template>
<!-- inline imported/included stylesheets -->
<xsl:mode name="inline" on-no-match="shallow-copy"/>
<xsl:template match="(xsl:import|xsl:include)[@href]" mode="inline">
<xsl:variable name="doc" as="document-node()"
select="document(resolve-uri(@href, .))"/>
<xsl:apply-templates select="$doc" mode="#current"/>
</xsl:template>
<!-- flatten nested stylesheets -->
<xsl:mode name="flatten" on-no-match="shallow-copy"/>
<xsl:template match="/*//xsl:stylesheet" mode="flatten">
<xsl:apply-templates select="node()" mode="#current"/> <!-- unwrap nested
stylesheet elements -->
</xsl:template>
<xsl:template match="/xsl:stylesheet" mode="flatten">
<xsl:copy>
<xsl:apply-templates select="namespace::*|//xsl:stylesheet/namespace::*"
mode="#current"/> <!-- pull nested stylesheet namespaces to the top -->
<xsl:apply-templates select="@*|//xsl:stylesheet/@*" mode="#current"/>
<!-- pull nested stylesheet attributes to the top -->
<xsl:apply-templates select="node()" mode="#current"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This created a single stylesheet b hooray! But I could not use it in an
XSLT-fiddle because document() calls did not resolve. For example,
<xsl:variable name="variableFiles"
select="document($variableFiles.url)/langlist/lang" as="element(lang)*"/>
<xsl:sequence select="document(., $variableFiles[1])/*/*[@name = $id or @id =
$id]"/>
<xsl:variable name="msgdoc" select="document('platform:/config/messages.xml')"
as="document-node()?"/>
<xsl:variable name="targetDoc" as="document-node()?"
select="document($resourcePart, root(if(exists($baseContextElement)) then
$baseContextElement else $linkElement))"/>
I think this could be handled with some more work in the inliner stylesheet,
but that is a project for a later day. If I get something working, Ibll
reply back here to share it!
* Chris
XSL-List info and
archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__
;!!A4F2R9G_pg!cEQO8g7FjKoj1kmYZuy-ZeKAp3yRgu6rpg-LTWD53jV984zbLhdtWFPghAPkocn
Q-ZHlK05gSwpX-GJ2D1SDojR9prlJH25FzdiZsUVct4mJvEEUOA9-$>
EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu
b/xsl-list/3380743__;!!A4F2R9G_pg!cEQO8g7FjKoj1kmYZuy-ZeKAp3yRgu6rpg-LTWD53jV
984zbLhdtWFPghAPkocnQ-ZHlK05gSwpX-GJ2D1SDojR9prlJH25FzdiZsUVct4mJvPZ0yIXb$>
(by email<>)
|