Michael Key's "A Proposal for XSLT 4.0" has spinned our interest in what could be added or changed in XSLT. This way we decided to implement Graph API purely in xslt. Our goal was to prove that:
At present we may confirm that first two goals are reachable; and experiments have shown that XSLT could provide more help to make program better, e.g. we have seen that language could simplify coding cycles.
Graph algorithms are often expressed with while cycles, e.g "Dijkstra's algorithm" has:
12 while Q is not empty: 13 u ← vertex in Q with min dist[u]
body is executed when condition is satisfied, but condition is impacted by body itself.
In xslt 3.0 we did this with simple recursion:
<xsl:template name="f:while" as="item()*"> <xsl:param name="condition" as="function(item()*) as xs:boolean"/> <xsl:param name="action" as="function(item()*) as item()*"/> <xsl:param name="next" as="function(item()*, item()*) as item()*"/> <xsl:param name="state" as="item()*"/> <xsl:if test="$condition($state)"> <xsl:variable name="items" as="item()*" select="$action($state)"/> <xsl:sequence select="$items"/> <xsl:call-template name="f:while"> <xsl:with-param name="condition" select="$condition"/> <xsl:with-param name="action" select="$action"/> <xsl:with-param name="next" select="$next"/> <xsl:with-param name="state" select="$next($state, $items)"/> </xsl:call-template> </xsl:if> </xsl:template>
But here is the point. It could be done in more comprehended way. E.g. to let xsl:iterate without select to cycle until xsl:break is reached.
xsl:iterate
select
xsl:break
<xsl:iterate> <xsl:param name="name" as="..." value="..."/> <xsl:if test="..."> <xsl:break/> </xsl:if> ... </xsl:iterate>
So, what we propose is to let xsl:iterate/@select to be optional, and change the behavior of processor when the attribute is missing from compilation error to a valid behavior. This should not impact on any existing valid XSLT 3.0 program.
xsl:iterate/@select