1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:f="http://www.functx.com">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="nodes" select="//*[@y]"/>
<xsl:variable name="all" select="$nodes/@y"/>
<xsl:variable name="distinct" select="distinct-values($all)"/>
<xsl:variable name="count" select="count($distinct)"/>
<xsl:variable name="seq_occ" as="item()*"/>
<xsl:template match="/">
<xsl:for-each select="$distinct">
<xsl:sort order="ascending" data-type="number" select="count($nodes[@y = current()])"/>
<output>
<xsl:value-of select="current()"/>###<xsl:value-of select="count($nodes[@y = current()])"/>
</output>
<xsl:variable name="var" select="f:append(count($nodes[@y = current()]))"/>
</xsl:for-each>
<seq_occ>
<xsl:value-of select="$seq_occ"/>
</seq_occ>
</xsl:template>
<xsl:function name="f:append" as="item()*">
<xsl:param name="input" as="xs:integer"/>
<xsl:sequence select="insert-before($seq_occ,1,$input)"/>
</xsl:function>
</xsl:stylesheet> |
Partager