I have a list of currency codes that I need to use to create currency pairs. Below is a (simplified) example
<?xml version="1.0" encoding="UTF-8"?>
<CurrencyLists>
<Currency>USD</Currency>
<Currency>BRL</Currency>
<Currency>EUR</Currency>
<Currency>GBP</Currency>
</CurrencyLists>
I'm trying to match each currency to the others to create a pair (cartesian product) like this USDBRL, USDEUR, USDGBP, BRLUSD, BRLEUR, BRLGBP, EURUSD, EURBRL, EURGBP (you get the idea)
I can loop in xslt and get each value but I'm not sure how to get the values a second time here is my sample xslt code
<xsl:template match="/">
<CurrencyPairs>
<Total>
<xsl:value-of select="count(CurrencyLists/Currency)"></xsl:value-of>
</Total>
<xsl:for-each select="CurrencyLists/Currency">
<!--<CurrencyPair><xsl:value-of select="."/></CurrencyPair>-->
<xsl:variable name="first" select="."/>
<first><xsl:value-of select="$first"/></first>
<!-- nested loop / cartesian here -->
</xsl:for-each>
</CurrencyPairs>
</xsl:template>
if I add a second for-each in the middle, I do not get any output. I searched here but didn't see anything that was relevant. I'm trying to make something that allows for more currency codes to be added (like JPY, CHF, THB) without having to create the pairs/cartesian product by hand (which is what I'm doing now)
thanks!