Stimulated by Henry Story's
blog entry, I wrote the equivalent in XQuery, and in doing so, bumped into some issues with the dbpedia data. In particular, there is no category I could find to identify a country, but then what constitutes a country depends on what the geographical entity is classified for, so this is to be expected.
In the end I resorted to scraping the wikipedia page which lists the codes directly.
Wikibook module