I just started using XSLT so I really need your help.
I have a list which contains an address branch like the following.
<addressList>
<address>
<uid>14666</uid>
<address1>PO Box 11365-171, Ferdowsi Avenue</address1>
<city>Tehran</city>
<country>Iran</country>
</address>
<address>
<uid>16967</uid>
<address1>43 Avenue Montaigne</address1>
<city>Paris</city>
<postalCode>75008</postalCode>
<country>France</country>
</address>
<address>
<uid>16968</uid>
<address1>Room 704-6, Wheelock Hse, 20 Pedder St, Central</address1>
<country>Hong Kong</country>
</address>
<address>
<uid>16969</uid>
<address1>Bank Melli Iran Bldg, 111 St 24, 929 Arasat</address1>
<city>Baghdad</city>
<country>Iraq</country>
</address>
<address>
<uid>16970</uid>
<address1>PO Box 2643, Ruwi</address1>
<city>Muscat</city>
<postalCode>112</postalCode>
<country>Oman</country>
</address>
<address>
<uid>16971</uid>
<address1>PO Box 2656, Liva Street</address1>
<city>Abu Dhabi</city>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16972</uid>
<address1>PO Box 248, Hamad Bin Abdulla St</address1>
<city>Fujairah</city>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16973</uid>
<address1>PO Box 1888, Clock Tower, Industrial Rd, Al Ain Club Bldg, Al Ain</address1>
<city>Abu Dhabi</city>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16974</uid>
<address1>PO Box 1894, Baniyas St, Deira</address1>
<city>Dubai City</city>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16975</uid>
<address1>PO Box 5270, Oman Street Al Nakheel</address1>
<city>Ras Al-Khaimah</city>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16976</uid>
<address1>PO Box 459, Al Borj St</address1>
<city>Sharjah</city>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16977</uid>
<address1>PO Box 3093, Ahmed Seddiqui Bldg, Khalid Bin El-Walid St, Bur-Dubai</address1>
<city>Dubai City</city>
<postalCode>3093</postalCode>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16978</uid>
<address1>PO Box 1894, Al Wasl Rd, Jumeirah</address1>
<city>Dubai</city>
<country>United Arab Emirates</country>
</address>
<address>
<uid>16979</uid>
<address1>Postfach 112 129, Holzbruecke 2, D-20459</address1>
<city>Hamburg</city>
<country>Germany</country>
</address>
<address>
<uid>16980</uid>
<address1>Nobel Ave. 14</address1>
<city>Baku</city>
<country>Azerbaijan</country>
</address>
<address>
<uid>16981</uid>
<address1>Unit 1703-4, 17th Floor, Hong Kong Club Building, 3 A Chater Road Central</address1>
<country>Hong Kong</country>
</address>
<address>
<uid>20368</uid>
<address1>Esteghlal St., Opposite to Otbeh Ibn Ghazvan Hall</address1>
<city>Basrah</city>
<country>Iraq</country>
</address>
</addressList>
I use XSLT to change the format of the XML list so I can import it into a different program. So for each address branch I want to get a different address branch.
I get this by using this XSLT part:
<xsl:for-each select="addressList/address">
<Country>
<CountryCode>
<xsl:choose>
<xsl:when test="country='Afghanistan'">AF</xsl:when>
<xsl:when test="country='Åland Islands'">AX</xsl:when>
<xsl:when test="country='Albania'">AL</xsl:when>
<xsl:when test="country='Algeria'">DZ</xsl:when>
<xsl:when test="country='American Samoa'">AS</xsl:when>
<xsl:when test="country='Andorra'">AD</xsl:when>
<xsl:when test="country='Angola'">AO</xsl:when>
<xsl:when test="country='Anguilla'">AI</xsl:when>
<xsl:when test="country='Antarctica'">AQ</xsl:when>
<xsl:when test="country='Antigua and Barbuda'">AG</xsl:when>
<xsl:when test="country='Argentina'">AR</xsl:when>
<xsl:when test="country='Armenia'">AM</xsl:when>
<xsl:when test="country='Aruba'">AW</xsl:when>
<xsl:when test="country='Australia'">AU</xsl:when>
<xsl:when test="country='Austria'">AT</xsl:when>
<xsl:when test="country='Azerbaijan'">AZ</xsl:when>
<xsl:when test="country='Bahamas'">BS</xsl:when>
<xsl:when test="country='Bahrain'">BH</xsl:when>
<xsl:when test="country='Bangladesh'">BD</xsl:when>
<xsl:when test="country='Barbados'">BB</xsl:when>
<xsl:when test="country='Belarus'">BY</xsl:when>
<xsl:when test="country='Belgium'">BE</xsl:when>
<xsl:when test="country='Belize'">BZ</xsl:when>
<xsl:when test="country='Benin'">BJ</xsl:when>
<xsl:when test="country='Bermuda'">BM</xsl:when>
<xsl:when test="country='Bhutan'">BT</xsl:when>
<xsl:when test="country='Bolivia, Plurinational State of'">BO</xsl:when>
<xsl:when test="country='Bonaire, Sint Eustatius and Saba'">BQ</xsl:when>
<xsl:when test="country='Bosnia and Herzegovina'">BA</xsl:when>
<xsl:when test="country='Botswana'">BW</xsl:when>
<xsl:when test="country='Bouvet Island'">BV</xsl:when>
<xsl:when test="country='Brazil'">BR</xsl:when>
<xsl:when test="country='British Indian Ocean Territory'">IO</xsl:when>
<xsl:when test="country='Brunei Darussalam'">BN</xsl:when>
<xsl:when test="country='Bulgaria'">BG</xsl:when>
<xsl:when test="country='Burkina Faso'">BF</xsl:when>
<xsl:when test="country='Burundi'">BI</xsl:when>
<xsl:when test="country='Cambodia'">KH</xsl:when>
<xsl:when test="country='Cameroon'">CM</xsl:when>
<xsl:when test="country='Canada'">CA</xsl:when>
<xsl:when test="country='Cape Verde'">CV</xsl:when>
<xsl:when test="country='Cayman Islands'">KY</xsl:when>
<xsl:when test="country='Central African Republic'">CF</xsl:when>
<xsl:when test="country='Chad'">TD</xsl:when>
<xsl:when test="country='Chile'">CL</xsl:when>
<xsl:when test="country='China'">CN</xsl:when>
<xsl:when test="country='Christmas Island'">CX</xsl:when>
<xsl:when test="country='Cocos (Keeling) Islands'">CC</xsl:when>
<xsl:when test="country='Colombia'">CO</xsl:when>
<xsl:when test="country='Comoros'">KM</xsl:when>
<xsl:when test="country='Congo'">CG</xsl:when>
<xsl:when test="country='Congo, the Democratic Republic of the'">CD</xsl:when>
<xsl:when test="country='Cook Islands'">CK</xsl:when>
<xsl:when test="country='Costa Rica'">CR</xsl:when>
<xsl:when test="country='Côte d Ivoire'">CI</xsl:when>
<xsl:when test="country='Croatia'">HR</xsl:when>
<xsl:when test="country='Cuba'">CU</xsl:when>
<xsl:when test="country='Curaçao'">CW</xsl:when>
<xsl:when test="country='Cyprus'">CY</xsl:when>
<xsl:when test="country='Czech Republic'">CZ</xsl:when>
<xsl:when test="country='Denmark'">DK</xsl:when>
<xsl:when test="country='Djibouti'">DJ</xsl:when>
<xsl:when test="country='Dominica'">DM</xsl:when>
<xsl:when test="country='Dominican Republic'">DO</xsl:when>
<xsl:when test="country='Ecuador'">EC</xsl:when>
<xsl:when test="country='Egypt'">EG</xsl:when>
<xsl:when test="country='El Salvador'">SV</xsl:when>
<xsl:when test="country='Equatorial Guinea'">GQ</xsl:when>
<xsl:when test="country='Eritrea'">ER</xsl:when>
<xsl:when test="country='Estonia'">EE</xsl:when>
<xsl:when test="country='Ethiopia'">ET</xsl:when>
<xsl:when test="country='Falkland Islands (Malvinas)'">FK</xsl:when>
<xsl:when test="country='Faroe Islands'">FO</xsl:when>
<xsl:when test="country='Fiji'">FJ</xsl:when>
<xsl:when test="country='Finland'">FI</xsl:when>
<xsl:when test="country='France'">FR</xsl:when>
<xsl:when test="country='French Guiana'">GF</xsl:when>
<xsl:when test="country='French Polynesia'">PF</xsl:when>
<xsl:when test="country='French Southern Territories'">TF</xsl:when>
<xsl:when test="country='Gabon'">GA</xsl:when>
<xsl:when test="country='Gambia'">GM</xsl:when>
<xsl:when test="country='Georgia'">GE</xsl:when>
<xsl:when test="country='Germany'">DE</xsl:when>
<xsl:when test="country='Ghana'">GH</xsl:when>
<xsl:when test="country='Gibraltar'">GI</xsl:when>
<xsl:when test="country='Greece'">GR</xsl:when>
<xsl:when test="country='Greenland'">GL</xsl:when>
<xsl:when test="country='Grenada'">GD</xsl:when>
<xsl:when test="country='Guadeloupe'">GP</xsl:when>
<xsl:when test="country='Guam'">GU</xsl:when>
<xsl:when test="country='Guatemala'">GT</xsl:when>
<xsl:when test="country='Guernsey'">GG</xsl:when>
<xsl:when test="country='Guinea'">GN</xsl:when>
<xsl:when test="country='Guinea-Bissau'">GW</xsl:when>
<xsl:when test="country='Guyana'">GY</xsl:when>
<xsl:when test="country='Haiti'">HT</xsl:when>
<xsl:when test="country='Heard Island and McDonald Islands'">HM</xsl:when>
<xsl:when test="country='Holy See (Vatican City State)'">VA</xsl:when>
<xsl:when test="country='Honduras'">HN</xsl:when>
<xsl:when test="country='Hong Kong'">HK</xsl:when>
<xsl:when test="country='Hungary'">HU</xsl:when>
<xsl:when test="country='Iceland'">IS</xsl:when>
<xsl:when test="country='India'">IN</xsl:when>
<xsl:when test="country='Indonesia'">ID</xsl:when>
<xsl:when test="country='Iran, Islamic Republic of'">IR</xsl:when>
<xsl:when test="country='Iran'">IR</xsl:when>
<xsl:when test="country='Iraq'">IQ</xsl:when>
<xsl:when test="country='Ireland'">IE</xsl:when>
<xsl:when test="country='Isle of Man'">IM</xsl:when>
<xsl:when test="country='Israel'">IL</xsl:when>
<xsl:when test="country='Italy'">IT</xsl:when>
<xsl:when test="country='Jamaica'">JM</xsl:when>
<xsl:when test="country='Japan'">JP</xsl:when>
<xsl:when test="country='Jersey'">JE</xsl:when>
<xsl:when test="country='Jordan'">JO</xsl:when>
<xsl:when test="country='Kazakhstan'">KZ</xsl:when>
<xsl:when test="country='Kenya'">KE</xsl:when>
<xsl:when test="country='Kiribati'">KI</xsl:when>
<xsl:when test="country='Korea, Democratic Peoples Republic of'">KP</xsl:when>
<xsl:when test="country='Korea, Republic of'">KR</xsl:when>
<xsl:when test="country='Kuwait'">KW</xsl:when>
<xsl:when test="country='Kyrgyzstan'">KG</xsl:when>
<xsl:when test="country='Lao Peoples Democratic Republic'">LA</xsl:when>
<xsl:when test="country='Latvia'">LV</xsl:when>
<xsl:when test="country='Lebanon'">LB</xsl:when>
<xsl:when test="country='Lesotho'">LS</xsl:when>
<xsl:when test="country='Liberia'">LR</xsl:when>
<xsl:when test="country='Libya'">LY</xsl:when>
<xsl:when test="country='Liechtenstein'">LI</xsl:when>
<xsl:when test="country='Lithuania'">LT</xsl:when>
<xsl:when test="country='Luxembourg'">LU</xsl:when>
<xsl:when test="country='Macao'">MO</xsl:when>
<xsl:when test="country='Macedonia, the Former Yugoslav Republic of'">MK</xsl:when>
<xsl:when test="country='Madagascar'">MG</xsl:when>
<xsl:when test="country='Malawi'">MW</xsl:when>
<xsl:when test="country='Malaysia'">MY</xsl:when>
<xsl:when test="country='Maldives'">MV</xsl:when>
<xsl:when test="country='Mali'">ML</xsl:when>
<xsl:when test="country='Malta'">MT</xsl:when>
<xsl:when test="country='Marshall Islands'">MH</xsl:when>
<xsl:when test="country='Martinique'">MQ</xsl:when>
<xsl:when test="country='Mauritania'">MR</xsl:when>
<xsl:when test="country='Mauritius'">MU</xsl:when>
<xsl:when test="country='Mayotte'">YT</xsl:when>
<xsl:when test="country='Mexico'">MX</xsl:when>
<xsl:when test="country='Micronesia, Federated States of'">FM</xsl:when>
<xsl:when test="country='Moldova, Republic of'">MD</xsl:when>
<xsl:when test="country='Monaco'">MC</xsl:when>
<xsl:when test="country='Mongolia'">MN</xsl:when>
<xsl:when test="country='Montenegro'">ME</xsl:when>
<xsl:when test="country='Montserrat'">MS</xsl:when>
<xsl:when test="country='Morocco'">MA</xsl:when>
<xsl:when test="country='Mozambique'">MZ</xsl:when>
<xsl:when test="country='Myanmar'">MM</xsl:when>
<xsl:when test="country='Namibia'">NA</xsl:when>
<xsl:when test="country='Nauru'">NR</xsl:when>
<xsl:when test="country='Nepal'">NP</xsl:when>
<xsl:when test="country='Netherlands'">NL</xsl:when>
<xsl:when test="country='New Caledonia'">NC</xsl:when>
<xsl:when test="country='New Zealand'">NZ</xsl:when>
<xsl:when test="country='Nicaragua'">NI</xsl:when>
<xsl:when test="country='Niger'">NE</xsl:when>
<xsl:when test="country='Nigeria'">NG</xsl:when>
<xsl:when test="country='Niue'">NU</xsl:when>
<xsl:when test="country='Norfolk Island'">NF</xsl:when>
<xsl:when test="country='Northern Mariana Islands'">MP</xsl:when>
<xsl:when test="country='Norway'">NO</xsl:when>
<xsl:when test="country='Oman'">OM</xsl:when>
<xsl:when test="country='Pakistan'">PK</xsl:when>
<xsl:when test="country='Palau'">PW</xsl:when>
<xsl:when test="country='Palestine, State of'">PS</xsl:when>
<xsl:when test="country='Palestinian'">PS</xsl:when>
<xsl:when test="country='Panama'">PA</xsl:when>
<xsl:when test="country='Papua New Guinea'">PG</xsl:when>
<xsl:when test="country='Paraguay'">PY</xsl:when>
<xsl:when test="country='Peru'">PE</xsl:when>
<xsl:when test="country='Philippines'">PH</xsl:when>
<xsl:when test="country='Pitcairn'">PN</xsl:when>
<xsl:when test="country='Poland'">PL</xsl:when>
<xsl:when test="country='Portugal'">PT</xsl:when>
<xsl:when test="country='Puerto Rico'">PR</xsl:when>
<xsl:when test="country='Qatar'">QA</xsl:when>
<xsl:when test="country='Réunion'">RE</xsl:when>
<xsl:when test="country='Romania'">RO</xsl:when>
<xsl:when test="country='Russia'">RU</xsl:when>
<xsl:when test="country='Rwanda'">RW</xsl:when>
<xsl:when test="country='Saint Barthélemy'">BL</xsl:when>
<xsl:when test="country='Saint Helena, Ascension and Tristan da Cunha'">SH</xsl:when>
<xsl:when test="country='Saint Kitts and Nevis'">KN</xsl:when>
<xsl:when test="country='Saint Lucia'">LC</xsl:when>
<xsl:when test="country='Saint Martin (French part)'">MF</xsl:when>
<xsl:when test="country='Saint Pierre and Miquelon'">PM</xsl:when>
<xsl:when test="country='Saint Vincent and the Grenadines'">VC</xsl:when>
<xsl:when test="country='Samoa'">WS</xsl:when>
<xsl:when test="country='San Marino'">SM</xsl:when>
<xsl:when test="country='Sao Tome and Principe'">ST</xsl:when>
<xsl:when test="country='Saudi Arabia'">SA</xsl:when>
<xsl:when test="country='Senegal'">SN</xsl:when>
<xsl:when test="country='Serbia'">RS</xsl:when>
<xsl:when test="country='Seychelles'">SC</xsl:when>
<xsl:when test="country='Sierra Leone'">SL</xsl:when>
<xsl:when test="country='Singapore'">SG</xsl:when>
<xsl:when test="country='Sint Maarten (Dutch part)'">SX</xsl:when>
<xsl:when test="country='Slovakia'">SK</xsl:when>
<xsl:when test="country='Slovenia'">SI</xsl:when>
<xsl:when test="country='Solomon Islands'">SB</xsl:when>
<xsl:when test="country='Somalia'">SO</xsl:when>
<xsl:when test="country='South Africa'">ZA</xsl:when>
<xsl:when test="country='South Georgia and the South Sandwich Islands'">GS</xsl:when>
<xsl:when test="country='South Sudan'">SS</xsl:when>
<xsl:when test="country='Spain'">ES</xsl:when>
<xsl:when test="country='Sri Lanka'">LK</xsl:when>
<xsl:when test="country='Sudan'">SD</xsl:when>
<xsl:when test="country='Suriname'">SR</xsl:when>
<xsl:when test="country='Svalbard and Jan Mayen'">SJ</xsl:when>
<xsl:when test="country='Swaziland'">SZ</xsl:when>
<xsl:when test="country='Sweden'">SE</xsl:when>
<xsl:when test="country='Switzerland'">CH</xsl:when>
<xsl:when test="country='Syrian Arab Republic'">SY</xsl:when>
<xsl:when test="country='Taiwan, Province of China'">TW</xsl:when>
<xsl:when test="country='Tajikistan'">TJ</xsl:when>
<xsl:when test="country='Tanzania, United Republic of'">TZ</xsl:when>
<xsl:when test="country='Thailand'">TH</xsl:when>
<xsl:when test="country='Timor-Leste'">TL</xsl:when>
<xsl:when test="country='Togo'">TG</xsl:when>
<xsl:when test="country='Tokelau'">TK</xsl:when>
<xsl:when test="country='Tonga'">TO</xsl:when>
<xsl:when test="country='Trinidad and Tobago'">TT</xsl:when>
<xsl:when test="country='Tunisia'">TN</xsl:when>
<xsl:when test="country='Turkey'">TR</xsl:when>
<xsl:when test="country='Turkmenistan'">TM</xsl:when>
<xsl:when test="country='Turks and Caicos Islands'">TC</xsl:when>
<xsl:when test="country='Tuvalu'">TV</xsl:when>
<xsl:when test="country='Uganda'">UG</xsl:when>
<xsl:when test="country='Ukraine'">UA</xsl:when>
<xsl:when test="country='United Arab Emirates'">AE</xsl:when>
<xsl:when test="country='United Kingdom'">GB</xsl:when>
<xsl:when test="country='United States'">US</xsl:when>
<xsl:when test="country='United States Minor Outlying Islands'">UM</xsl:when>
<xsl:when test="country='Uruguay'">UY</xsl:when>
<xsl:when test="country='Uzbekistan'">UZ</xsl:when>
<xsl:when test="country='Vanuatu'">VU</xsl:when>
<xsl:when test="country='Venezuela. Bolivarian Republic of'">VE</xsl:when>
<xsl:when test="country='Viet Nam'">VN</xsl:when>
<xsl:when test="country='Virgin Islands, British'">VG</xsl:when>
<xsl:when test="country='Virgin Islands, U.S.'">VI</xsl:when>
<xsl:when test="country='Wallis and Futuna'">WF</xsl:when>
<xsl:when test="country='Western Sahara'">EH</xsl:when>
<xsl:when test="country='Yemen'">YE</xsl:when>
<xsl:when test="country='Zambia'">ZM</xsl:when>
<xsl:when test="country='Zimbabwe'">ZW</xsl:when>
<xsl:otherwise>CU</xsl:otherwise>
</xsl:choose>
</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
</xsl:for-each>
And the output would be the following:
<Country>
<CountryCode>IR</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>FR</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>HK</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>IQ</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>OM</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>DE</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>AZ</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>HK</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
<Country>
<CountryCode>IQ</CountryCode>
<CountryTypeCode>COUNTRY_OF_REGISTRATION</CountryTypeCode>
</Country>
The problem that I have is that I have duplicates in the <CountryCode>
section. Is there a possibility to identify these duplicates and eliminate them so it only shows them once?
I would be very thankful if some of you could maybe help me!