21. Saxon-JS
Is this an XML problem? Of course it is. At its core, it’s just an “almost identity” transformation:
1<xsl:template match="td[@data-slot]">
<xsl:variable name="event" select="key('slot', @data-slot)"/>
<xsl:copy>
5 <xsl:apply-templates select="@* except @class"/>
<xsl:choose>
<xsl:when test="$event">
<xsl:sequence select="f:event-class(@class, $event)"/>
10 <xsl:apply-templates select="$event"
mode="data-content"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class"
15 select="normalize-space(@class || ' none')"/>
<xsl:text>No talk scheduled.</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
20</xsl:template>