2014-03-05 28 views
0

在Oracle Service Bus中,我需要'ISO 3166-1 alpha-2'和'ISO 3166-1 alpha-3'國家代碼。 目前我使用Java Callout來獲得相同的(我想避免)。用於iso國家代碼的XQuery函數或庫?

我對這兩種技術都很陌生,也不瞭解標準實踐,所以只是想檢查一下您的意見。

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. 

謝謝。

+0

你到底想要做的,找到一個國名的國家代碼? –

+0

我想將ISO 2國家代碼轉換爲ISO 3國家代碼。例如'GB'到'GBR'。 –

回答

3

我不知道現有的提供該功能的XQuery模塊。但是所有代碼都可以從ISO Online Browsing Platform獲得,您可以輕鬆構建自己的代碼。

我從當前分配的所有代碼快速生成了一個XML文檔,它可以在https://gist.github.com/LeoWoerteler/9388743找到。利用這一點,從的α-2的α-3代碼轉換可以做如下:

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' :) 
0

你可以使用ISO 2字母國家代碼從這裏:http://www.codesynthesis.com/projects/xsstl/xsstl/iso3166-country-code.xsd

根據該文件,你可以使用類似下面通過自己的國家代碼查找國家:

declare namespace xsd = "http://www.w3.org/2001/XMLSchema"; 

replace(//xsd:enumeration[@value eq 'BV']/following-sibling::comment()[1], "<!-- (.*) -->", "$1") 

個人而言,我會變換架構文檔轉換爲簡單的XML文檔,從註釋中提取國家名稱,以便我不必自己查詢註釋。