|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<xsl:stylesheet xmlns:dow="urn:dow-functions"
|
|
xmlns:local="urn:local-functions"
|
|
xmlns:saxon="http://saxon.sf.net/"
|
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
version="2.0">
|
|
<xsl:import href="day-of-week.xslt"/>
|
|
<xsl:output method="text" omit-xml-declaration="yes"/>
|
|
|
|
<xsl:template name="xsl:initial-template" match="/">
|
|
<xsl:variable name="startTime" select="saxon:timestamp()"/>
|
|
<xsl:sequence select="$startTime[local:always-false()]"/>
|
|
<xsl:sequence select="local:log('Batch execution starting...')"/>
|
|
<xsl:call-template name="local:test"/>
|
|
<xsl:sequence select="local:log('Batch execution succeeded')"/>
|
|
<xsl:sequence select="local:log-execution-time($startTime)"/>
|
|
</xsl:template>
|
|
|
|
<xsl:function name="local:always-false" as="xs:boolean">
|
|
<xsl:sequence select="current-date() lt xs:date('2000-01-01')"/>
|
|
</xsl:function>
|
|
|
|
<xsl:function name="local:log">
|
|
<xsl:param name="message" as="item()*"/>
|
|
<xsl:message select="serialize($message)"/>
|
|
</xsl:function>
|
|
|
|
<xsl:function name="local:log-execution-time">
|
|
<xsl:param name="startTime" as="xs:dateTime"/>
|
|
<xsl:sequence select="local:log(concat('Execution time: ', (saxon:timestamp() - $startTime) div xs:dayTimeDuration('PT1S'), 's'))"/>
|
|
</xsl:function>
|
|
|
|
<xsl:template name="local:test">
|
|
<xsl:variable name="feastday" select="('2023-12-25','2024-01-01','2024-04-01','2024-05-01')"/>
|
|
<xsl:variable name="continuous-valday" as="map(*)*">
|
|
<xsl:sequence select="map{'R':7,'validFromDate':'2023-12-10','validToDate':'2023-12-10'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2023-12-16','validToDate':'2023-12-17'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2023-12-23','validToDate':'2023-12-25'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2023-12-30','validToDate':'2024-01-01'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-01-06','validToDate':'2024-01-07'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-01-13','validToDate':'2024-01-14'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-01-20','validToDate':'2024-01-21'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-01-27','validToDate':'2024-01-28'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-02-03','validToDate':'2024-02-04'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-02-10','validToDate':'2024-02-11'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-02-17','validToDate':'2024-02-18'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-02-24','validToDate':'2024-02-25'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-03-02','validToDate':'2024-03-03'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-03-09','validToDate':'2024-03-10'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-03-16','validToDate':'2024-03-17'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-03-23','validToDate':'2024-03-24'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-03-30','validToDate':'2024-04-01'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-04-06','validToDate':'2024-04-07'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-04-13','validToDate':'2024-04-14'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-04-20','validToDate':'2024-04-21'}"/>
|
|
<xsl:sequence select="map{'R':(6,7),'validFromDate':'2024-04-27','validToDate':'2024-04-28'}"/>
|
|
<xsl:sequence select="map{'R':7,'validFromDate':'2024-05-01','validToDate':'2024-05-01'}"/>
|
|
</xsl:variable>
|
|
<xsl:sequence select="local:log('input:')"/>
|
|
<xsl:sequence select="dow:valday-to-string($continuous-valday)!local:log(.)"/>
|
|
<xsl:variable name="valday" select="dow:merge-valday($continuous-valday, $feastday)"/>
|
|
<xsl:sequence select="local:log('output:')"/>
|
|
<xsl:sequence select="dow:valday-to-string($valday)!local:log(.)"/>
|
|
</xsl:template>
|
|
|
|
</xsl:stylesheet>
|