C I A   W O R L D   F A C T B O O K
Here is an example of how to create an archive for previous annual releases of the CIA World Factbook that are available in XML-format from our Web-site.
Files
For this example you need the following files:
2004.xml.gz The 2004 release of the CIA World Factbook
2005.xml.gz The 2005 release of the CIA World Factbook
2006.xml.gz The 2006 release of the CIA World Factbook
CIAWFB.keys The key specification needed when merging the CIA World Factbook versions into an archive.
Commands
In order to create a new archive for the CIA World Factbook use the following command:
CREATE ARCHIVE CIAWFB OF XML
To merge the different releases of the CIA World Factbook into the new archive CIAWFB use the following command:
INSERT INTO CIAWFB AS 2004 FROM TYPE XML XML_FILENAME=2004.xml.gz, COMPRESSED=true, SCHEMA=CIAWFB.keys
You may either download the above files to your local machine and adjust the path names accordingly or use the files directly on the Web, i.e.,
INSERT INTO CIAWFB AS 2004 FROM TYPE XML XML_FILENAME=http://homepages.inf.ed.ac.uk/
hmueller/xarch/data/ciawfb/2004.xml.gz, COMPRESSED=true, SCHEMA=http://homepages.inf.ed.ac.uk/
hmueller/xarch/data/ciawfb/CIAWFB.keys
Merge the other two files accordingly. Since the schema of all three Factbook versions doesn't change one may want to omit the schema parameter in the INSERT-statement. To be able to do so the archive can be created with a default schema:
CREATE ARCHIVE CIAWFB OF XML HAVING PROPERTIES DEFAULT_SCHEMA=http://homepages.inf.ed.ac.uk/
hmueller/xarch/data/ciawfb/CIAWFB.keys
You may also use the W3X-driver to access an existing example archive on the Web containing the above files:
CREATE ARCHIVE CIAWFB OF W3X HAVING PROPERTIES
URL=http://www.molgen.mpg.de/~heiko/archives/ciawfb/CIAWFB.archive
Alternatively, you can use the build-in parser for the current CIA Web pages to download (and merge) a XML version of the current Factbook content. Use the following command after creating the archive as described above:
INSERT INTO CIAWFB FROM TYPE CIAWEB
DOCUMENT=FACTBOOK
Every time you execute the insert command the current data will be downloaded, transformed into XML, and merged into your archive. Be aware that this process may take several minutes due to the data download!
After creating the archive you can view the contents using the following simple query:
SELECT * FROM CIAWFB
If you are only interested in seeing the 2004 release of the CIA World Factbook use the following query:
SELECT * FROM CIAWFB VERSION 2004
The following query shows how the population of European countries changed during the period from 2004-2005:
SELECT C/NAME, /CIAWFB/COUNTRY/CATEGORY('People')/PROPERTY('Population')
FROM CIAWFB
WITH /CIAWFB/COUNTRY AS C
VERSION 2004-2005
WHERE C/CATEGORY('Geography')/PROPERTY('Map references')/TEXT = 'Europe'