<for-each select="$lines[not(position()=1) and starts-with(., '%%')]">
<variable name="end" select="."/>
<variable name="start" select="preceding-sibling::*[starts-with(., '%%')][1]"/>
<for-each select="$lines[not(position()=1) and starts-with(., '%%')]">
<variable name="end" select="."/>
<variable name="start" select="preceding-sibling::*[starts-with(., '%%')][1]"/>