Still found the time to correct a typo and to remove the redundant
distinct-values():
<xsl:function name="my:sortkey" as="xs:integer">
<xsl:param name="input" as="element(*)" />
<xsl:param name="seen" as="xs:string*" />
<xsl:if test="name($input) = $seen">
<xsl:message terminate="yes">Element
<xsl:value-of select="name($input)"/>
doesn't seem to occur at a deterministic
position.
</xsl:message>
</xsl:if>
<xsl:variable
name="preceding-siblings"
select="$input/../../seq/*[
name() = name($input)
]/preceding-sibling::*[1]"
as="element(*)*" />
<xsl:variable name="seen" select="($seen, name($input))" />
<xsl:sequence select="(
max(
for $ps in $preceding-siblings
return my:sortkey($ps, $seen)
) + 1,
1
)[1]"/>
<!-- short form of if(not(empty($preceding-siblings))) -->
</xsl:function>
On 08.04.2010 18:07, Imsieke, Gerrit, le-tex wrote:
<xsl:function name="my:sortkey" as="xs:integer">
<xsl:param name="input" as="element(*)" />
<xsl:param name="previously-seen" as="xs:string*" />
<xsl:if test="name($input) = $previously-seen">
<xsl:message terminate="yes">Element <xsl:value-of
select="name($input)"/> doesn't seem to occur at an deterministic position.
</xsl:message>
</xsl:if>
<xsl:variable name="preceding-siblings"
select="$input/../../seq/*[name() =
name($input)]/preceding-sibling::*[1]" as="element(*)*" />
<xsl:variable name="seen" select="distinct-values(($previously-seen,
name($input)))" />
<xsl:sequence select="(max(for $ps in $preceding-siblings return
my:sortkey($ps, $seen)) + 1, 1)[1]"/>
</xsl:function>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--