The XSL will compile to the .sef file but in the inspect of firefox I get "Transformation failure: Error XPDY0002 at line #34 Focus for . (dot) is absent".
From my very limited knowledge, this saxon error is from not making a template the main template so why would it be tripped on a for-each?
The XSL file
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT"
xmlns:saxon="http://saxon.sf.net/"
xmlns:js="http://saxonica.com/ns/globalJS"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
exclude-result-prefixes="#all"
version="2.0">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:output method="html" encoding="utf-8" indent="yes" />
<xsl:template name="xsl:initial-template" match="/">
<h1 align="center">Pack Schedule</h1>
<table border="3" align="center" >
<tr>
<th>Complete by</th>
<th>How Many Days Past</th>
</tr>
<xsl:for-each select="order/job">
<xsl:sort select="Complete_by"/>
<xsl:variable name="dueDateOP" select="xs:date(Complete_by)"/>
<xsl:variable name="daysOut" select="(current-date() - $dueDateOP)"/>
<xsl:variable name="daysOutDated" select="fn:days-from-duration($daysOut)"/>
<xsl:choose>
<xsl:when test="$daysOutDated >= 14">
<tr bgcolor="red">
<td><xsl:value-of select="Complete_by"/></td>
<td><xsl:value-of select="$daysOutDated" /></td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr bgcolor="yellow">
<td><xsl:value-of select="Complete_by"/></td>
<td><xsl:value-of select="$daysOutDated" /></td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
The XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="pack3.xsl" ?>
<order>
<job>
<Complete_by> 2022-05-17</Complete_by>
<Comments> </Comments>
<Updated> 5/26/2022 10:05:31 AM</Updated>
</job>
<job>
<Complete_by> 2022-05-27</Complete_by>>
<Comments> </Comments>
<Updated> 5/26/2022 10:05:31 AM</Updated>
</job>
<job>
<Complete_by> 2022-05-24</Complete_by>
<Comments> </Comments>
<Updated> 5/26/2022 10:05:31 AM</Updated>
</job>
<job>
<Complete_by> 2022-06-17</Complete_by>
<Comments> </Comments>
<Updated> 5/26/2022 10:05:31 AM</Updated>
</job>
<job>
<Complete_by> 2022-04-17</Complete_by>
<Comments> </Comments>
<Updated> 5/26/2022 10:05:31 AM</Updated>
</job>
</order>
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Days spent</title>
<script type="text/javascript" src="saxon-js/SaxonJS2.rt.js"></script>
<script type="text/javascript">
window.onload = function() {
SaxonJS.transform({
stylesheetLocation: "pack3.sef.json"
}, "async");
}
</script>
<script>console.log(SaxonJS.getProcessorInfo())</script>
</head>
<body id="body">
<h1>There is an error</h1>
</body>
</html>