<?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:for-each>
            <xsl:for-each select="document($PARTICIPANT-FILE)/results/participantref">
                <participantref><xsl:value-of select="."/></participantref>
            </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>
        </result>
    </xsl:template>
</xsl:stylesheet>
