24. Saxon-JS: Updating the browser web page
It’s impractical to expose an API like
innerHTML
from within XSLT.Instead, Saxon-JS leverages the existing mechanism for producing result documents
xsl:result-document
:<xsl:result-document href="#schedule">
<xsl:apply-templates select="ixsl:page()/html"/>
</xsl:result-document>
If the
href
attribute is a same-document fragment identifier, the resulting output is appended to the element with the corresponding ID.The extension method
ixsl:replace-content
instructs the processor to replace the content, rather than appending to it:<xsl:result-document href="#schedule" method="ixsl:replace-content">
<xsl:apply-templates select="ixsl:page()/html"/>
</xsl:result-document>
(It’s possible to write to any element, even elements that don’t have IDs, by making them the context node first.)