In Oracle Service Bus I need 'ISO 3166-1 alpha-2' and 'ISO 3166-1 alpha-3' country codes. At the moment I'm using Java Callout to get the same (which I would like to avoid).
I'm new to both these technologies and unaware of the standard practices so just wanted to check your opinion.
1. I was just wondering if there are any XQuery libraries which could provide country codes.
2. Considering most probably these values are going to be constant, is it okay to handwrite the function.
Thanks.
I don't know of an existing XQuery module that provides that functionality. But as all codes are available from the ISO Online Browsing Platform, you cal easily build your own.
I quickly generated an XML document from all currently assigned codes, which can be found at https://gist.github.com/LeoWoerteler/9388743. Using that, the conversion from alpha-2 to alpha-3 codes could be done as follows:
declare variable $iso_3166-1 := doc('iso_3166-1.xml')/iso_3166-1;
declare function local:alpha2-to-alpha3($code) as xs:string {
$iso_3166-1/country[@alpha-2 = $code]/@alpha-3
};
local:alpha2-to-alpha3('US') (: ==> 'USA' :)