I understand this question might be beyond Saxon and more related to the architecture of the application using it for transformations, but just wanted to give a try. Consider the following files-
XML
<?xml version="1.0" encoding="UTF-8"?>
<document>
string
</document>
XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xsl xs">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="node()">
<xsl:apply-templates select="."/>
</xsl:template>
</xsl:stylesheet>
The XSL will go into an infinite recursion during the transformation aka stack overflow. My question is- Is there a way to stop or prevent this type of transformation from going into an infinite recursion? Any parameters that can be added to the command-line that can trigger a warning and gracefully stop?
-quit:
(on
|off
) option, which determines whether Saxon quits the JVM or raises a runtime exception in case of failure. The latter is helpful if Saxon is being called from Java. If there were a way to detect infinite recursion statically, or prevent it, computer science would be very different. (By which I mean: no, Saxon doesn't have it, because Turing proved that it cannot be had.) – Geosyncline