Reputation: 2807
For reasons I won't go into, I can't use xsl:include in my production environment so when I write XSLT which uses xsl:includes I preprocess the XSLT files to simulate this instruction and produce a complete single XSLT file.
This is my pseudo xsl:include simulator.
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:mode on-no-match="shallow-copy" />
<xsl:template match="xsl:include">
<xsl:apply-templates select="document(@href)/xsl:stylesheet/*"/>
</xsl:template>
</xsl:stylesheet>
This works pretty well, BUT it irritatingly reformats the code, in a bad way, so code like this:
<xsl:map-entry
key="'meWatchPushDate'"
select="
function($tx)
{
( $tx/tx_starttimepoint/ESP_TIMEINSTANT/xs:dateTime(@full)
=> mgx:datetime_to_pushdateformat(),
''
)[1]
}"/>
gets mashed into
<xsl:map-entry key="'meWatchPushDate'"
select=" function($tx) { ( $tx/tx_starttimepoint/ESP_TIMEINSTANT/xs:dateTime(@full) => mgx:datetime_to_pushdateformat(), '' )[1] }"/>
which is a tad irritating.
(actually this is a duplicate! - duplicate)
I'm happy for any solution to include tips of formatting XPath expressions so that they don't get mashed.
(Its ironic that xslt is actually not capable of mapping itself without reformatting itself.)
Upvotes: 0
Views: 59
Reputation: 2807
There seems to be no way to do this in XSLT.
I'll probably try to do it in another language, my transforms are trivial (as you can see in the OP).
I'll post my results here, so at least people will know if this is an inherent/endemic issue with XML transforms, or an XSLT issue.
Upvotes: 0