<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="4.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:map="http://www.w3.org/2005/xpath-functions/map"
  xmlns:math="http://www.w3.org/2005/xpath-functions/math"
  xmlns:array="http://www.w3.org/2005/xpath-functions/array"
  xmlns:tm="http://www.datenverdrahten.de/tm"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="#all"
  expand-text="yes">
  
  <!-- by T. Meinike 11/22 -->

  <xsl:output method="json" encoding="UTF-8" indent="yes"/>

  <xsl:variable name="doc" select="document('test.xml')"/>

  <xsl:template name="xsl:initial-template">
    <xsl:apply-templates select="$doc/*"/>
  </xsl:template>

  <xsl:template match="data">
    <xsl:map on-duplicates="function($a, $b){array:join(($a, $b))}">
      <xsl:for-each select="event">
        <xsl:map-entry key="@id" select="[fn:number(@value)]"/>
      </xsl:for-each>
    </xsl:map>
  </xsl:template>

</xsl:stylesheet>