Project

Profile

Help

Bug #1745 ยป bug95.xsl

John Lumley, 2013-04-25 13:23

 
<?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:math="http://www.w3.org/2005/xpath-functions/math" xmlns:lay="http://jwlresearch.net/2012/layout"
xmlns:svg="http://www.w3.org/2000/svg" exclude-result-prefixes="xs math" version="3.0">

<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<foo>
<xsl:for-each select="1 to 4">
<!-- Under 9.5.0.1: OK if svg:join.line(), execution error if svg:join.orthogonal(),
Both OK under 9.4.0.7 -->
<xsl:sequence select="svg:join.orthogonal((0,0),(10,10))"/>
</xsl:for-each>
</foo>
</xsl:template>

<xsl:function name="svg:join" as="element()?">
<xsl:param name="points" as="xs:double*"/>
<svg:polyline fill="none" points="{$points}"/>
</xsl:function>
<xsl:function name="svg:join.line" as="element()?">
<xsl:param name="from" as="xs:double*"/>
<xsl:param name="to" as="xs:double*"/>
<xsl:sequence select="svg:join(($from,$to))"/>
</xsl:function>
<xsl:function name="svg:join.orthogonal" as="element()?">
<xsl:param name="from" as="xs:double*"/>
<xsl:param name="to" as="xs:double*"/>
<!-- Stack frame slot allocation issue with $y -->
<xsl:sequence
select="let $y := ($from[2] + $to[2]) div 2
return svg:join(($from,if($from[1] eq $to[1]) then () else (($from[1],$y),($to[1],$y)),$to))"
/>
</xsl:function>
<!-- Previously reported compiler NPE bug - issue #1744 -->
<xsl:function use-when="false()" name="lay:XXX" as="element()*">
<xsl:param name="children" as="element()*"/>
<xsl:variable name="head" select="head($children)"/>
<xsl:variable name="offsets" as="xs:double*">
<xsl:iterate select="tail($children)">
<xsl:param name="first" select="$head"/>
<xsl:next-iteration>
<xsl:with-param name="first" select="."/>
</xsl:next-iteration>
</xsl:iterate>
</xsl:variable>
<xsl:for-each select="$offsets">
<foo/>
</xsl:for-each>
</xsl:function>
</xsl:stylesheet>
    (1-1/1)