The given XML:
<records>
<record>
<country>Germany</country>
<value>123</value>
</record>
<record>
<country>Germany</country>
<value>62</value>
</record>
<record>
<country>Germany</country>
<value>033</value>
</record>
<record>
<country>Armenia</country>
<value>444</value>
</record>
<record>
<country>Armenia</country>
<value>212</value>
</record>
<record>
<country>Armenia</country>
<value>864</value>
</record>
</records>
How do I get an output, which respectively chooses every first occurrence of <record>
by the value of <country>
.
So the desired output should look like:
<records>
<record>
<country>Germany</country>
<value>123</value>
</record>
<record>
<country>Armenia</country>
<value>444</value>
</record>
</records>
UPDATE: Solved my Problem with given XSL
<xsl:key name="country" match="record" use="value" />
<xsl:template match="records">
<xsl:apply-templates select="record[1]" />
</xsl:template>
<xsl:template match="record">
<xsl:for-each select="key('country', value)">
<country><xsl:value-of select="country"/></country>
<value><xsl:value-of select="value"/></value>
</xsl:for-each>
</xsl:template>