This is an Open Web Archive archive of https://gitlab.dyomedea.com/presentations/xmlamsterdam2013/blob/master/boot-saxon.xsl.
This snapshot has been taken on 2014-01-08 21:07:43 for the website Eric van der Vlist which contains a link to this page and has saved a copy to be displayed in the page ever disappears.
presentations / XML Amsterdam 2013 | GitLab
boot-saxon.xsl 4.81 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2013 Eric van der Vlist <vdv@dyomedea.com>
See license information at the bottom of this file
-->

<!--
Saxon CE executes only the first script with @type="application/xslt+xml" and @language="xslt2.0"
found in a page.
When this script is run it executes all the other scripts from the document.

-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT" xmlns:js="http://saxonica.com/ns/globalJS"
xmlns:style="http://saxonica.com/ns/html-style-property"
xmlns:prop="http://saxonica.com/ns/html-property" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://dyomedea.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
extension-element-prefixes="ixsl" exclude-result-prefixes="xs xd d js" version="2.0">
<xsl:import href="indent.xsl"/>
<xsl:import href="serialization.xsl"/>
<xsl:include href="saxon-ce-dummy-declarations.xsl"/>

<xsl:variable name="tokens" select="tokenize(ixsl:get(ixsl:window(), 'location.href'), '/')"/>
<xsl:variable name="url-base" as="xs:string"
select="string-join(($tokens[position() &lt; count($tokens)], ''), '/')"/>
<xsl:variable name="non-cached-url"
select="concat(ixsl:get(ixsl:window(), 'location.href'), '?_dt_=', current-dateTime())"/>

<xsl:template name="init">
<ixsl:set-property name="xsltTransformations" select="()"/>
<ixsl:set-property name="otherXML" select="()"/>
<xsl:for-each select="ixsl:page()">
<xsl:variable name="processors" as="item()*">
<xsl:apply-templates
select="//script[@type='application/xslt+xml' and @language='xslt2.0'][position() > 1]"
/>
</xsl:variable>
<ixsl:set-property name="xsltProcessors" select="$processors"/>
</xsl:for-each>
</xsl:template>

<xsl:template match="script[@src]">
<!-- Read the transformation -->
<xsl:variable name="transformation" select="js:Saxon.requestXML(string(@src))"/>
<!-- Apply the transformation -->
<xsl:variable name="xsltProcessor" select="js:Saxon.newXSLT20Processor($transformation)"/>
<ixsl:set-property name="dummy"
select="ixsl:call($xsltProcessor, 'setInitialTemplate', string(@data-initial-template))"/>
<ixsl:set-property name="dummy" select="ixsl:call($xsltProcessor, 'updateHTMLDocument', ())"/>
<!-- Keep a copy for the introspection -->
<ixsl:set-property name="xsltTransformations"
select="(ixsl:get(ixsl:window(), 'xsltTransformations'), $transformation)"/>
<xsl:sequence select="$xsltProcessor"/>
</xsl:template>

<!-- Dynamic transformation applied on the initial source of the page -->
<xsl:template match="script[not(@src) and @data-transformation]">
<!-- Compile the transformation -->
<xsl:variable name="xsltProcessor1"
select="js:Saxon.newXSLT20Processor(js:Saxon.requestXML(string(@data-transformation)))"/>
<ixsl:set-property name="dummy"
select="ixsl:call($xsltProcessor1, 'setParameter', '', 'url-base', $url-base )"/>
<xsl:variable name="transformation"
select="ixsl:call($xsltProcessor1, 'transformToDocument', js:Saxon.requestXML($non-cached-url))"/>
<!-- Keep a copy for the introspection -->
<ixsl:set-property name="xsltTransformations"
select="(ixsl:get(ixsl:window(), 'xsltTransformations'), $transformation)"/>
<xsl:variable name="xsltProcessor" select="js:Saxon.newXSLT20Processor($transformation)"/>
<ixsl:set-property name="dummy"
select="ixsl:call($xsltProcessor, 'setInitialTemplate', string(@data-initial-template))"/>
<ixsl:set-property name="dummy" select="ixsl:call($xsltProcessor, 'updateHTMLDocument', ())"/>
<xsl:sequence select="$xsltProcessor"/>
</xsl:template>

</xsl:stylesheet>
<!--
Copyright © 2013 Eric van der Vlist <vdv@dyomedea.com>
This file is part of
<https://gitlab.dyomedea.com/public/projects/presentations/xmlamsterdam2013>.
This sotfware is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This sotfware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
-->