Hallo Julian,
war gerade am ersten XML-Code dran, als Du wieder mal die Perspektive gewechselt hast.
Probiere es so:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="header_text" match="HeaderText" use="Qualifier"/>
<xsl:key name="line_text" match="LineText" use="Qualifier"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="HeaderText">
<xsl:for-each select=".[generate-id() = generate-id(key('header_text', Qualifier)[1])]">
<HeaderText>
<xsl:copy-of select="Qualifier"/>
<Text>
<xsl:for-each select="key('header_text', Qualifier)">
<xsl:value-of select="Text"/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</Text>
</HeaderText>
</xsl:for-each>
</xsl:template>
<xsl:template match="LineText">
<xsl:for-each select=".[generate-id() = generate-id(key('line_text', Qualifier)[1])]">
<LineText>
<xsl:copy-of select="Qualifier"/>
<Text>
<xsl:for-each select="key('line_text', Qualifier)">
<xsl:value-of select="Text"/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</Text>
</LineText>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Grüße,
Thomas