<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:param name="PARTICIPANT-FILE"/>
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <results>
            <xsl:for-each select="results/participantref">
                <xsl:copy-of select="."/>
                <xsl:copy-of select="following-sibling::endpoints[1]"/>
            </xsl:for-each>
<!--            <xsl:for-each select="results/endpoints">
                <xsl:copy-of select="."/>
            </xsl:for-each>-->
            <xsl:for-each select="document($PARTICIPANT-FILE)/results">
                <xsl:for-each select="participantref">
                    <participantref>
                        <xsl:value-of select="."/>
                    </participantref>
                    <xsl:copy-of select="following-sibling::endpoints[1]"/>
                </xsl:for-each>
<!--                <xsl:for-each select="endpoints">
                    <xsl:copy-of select="."/>
                </xsl:for-each>-->
            </xsl:for-each>
            <xsl:for-each select="results/result">
                <xsl:copy-of select="."/>
            </xsl:for-each>
            <xsl:for-each select="document($PARTICIPANT-FILE)/results/result">
                <xsl:call-template name="create-result"/>
            </xsl:for-each>
        </results>
    </xsl:template>
    <xsl:template name="create-result">
        <result>
            <testcaseref>
                <xsl:value-of select="testcaseref"/>
            </testcaseref>
            <passed>
                <xsl:value-of select="passed"/>
            </passed>
            <participantref>
                <xsl:value-of select="../participantref"/>
            </participantref>
            <provider>
                <xsl:value-of select="provider"/>
            </provider>
        </result>
    </xsl:template>
</xsl:stylesheet>
