在Oracle服务总线中,我需要“ISO 3166-1 alpha-2”和“ISO 3166-1 alpha-3”国家代码。目前,我正在使用Java标注来获取相同的内容(我想避免这种情况)。
我对这两种技术都很陌生,也不知道标准实践,所以我只想看看你的看法。
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.谢谢。
发布于 2014-03-06 12:54:48
我不知道有一个现有的XQuery模块能够提供这种功能。但是由于所有代码都可以从ISO在线浏览平台中获得,所以您可以轻松地构建自己的代码。
我从所有当前分配的代码中快速生成了一个XML文档,这些代码可以在https://gist.github.com/LeoWoerteler/9388743上找到。使用它,从alpha-2到alpha-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' :)发布于 2014-03-05 16:12:47
您可以从这里使用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")就我个人而言,我会将该Schema文档转换为一个简单的XML文档,从注释中提取国家名称,这样我就不必查询注释本身。
https://stackoverflow.com/questions/22201615
复制相似问题