XForms Everywhere

4/6/2006

XML and XForms Can Really be More Productive

Filed under: General — Erik Bruchez @ 10:20 am

Country List

I just hit a really telling example of how XML and XForms can deliver incredible productivity. The requirement: creating a dropdown menu displaying the list of all the world’s countries in French, using ISO names and codes. Here is how you do it with XForms:

  1. Download the XML file containing the list of countries from ISO (after finding it with Google). The file contains entries of the type:

    <ISO_3166-1_Entry>
        <ISO_3166-1_Country_name>SUISSE</ISO_3166-1_Country_name>
        <ISO_3166-1_Alpha-2_code>CH</ISO_3166-1_Alpha-2_code>
    </ISO_3166-1_Entry>
    
  2. Import the file in your XForms page with:

    <xforms:instance id="countries-instance" src="iso_3166-1_list_fr.xml"/>
    
  3. Refer to the list of country from the select1 control:

    <xforms:select1 ref="country" appearance="minimal">
        <xforms:label>Country</xforms:label>
        <xforms:itemset nodeset="instance('countries-instance')/*">
            <xforms:label ref="ISO_3166-1_Country_name"/>
            <xforms:value ref="ISO_3166-1_Alpha-2_code"/>
        </xforms:itemset>
    </xforms:select1>
    

And that’s it! Can you actually imagine anything simpler, in any language?

2 Comments »

  1. For those people that want to read that page in English, you can simply replace the ‘fr’ in the URL with ‘en’.

    http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html

    I’m assuming that other languages are possible.

    Comment by duck1123 — 5/1/2006 @ 12:28 pm

  2. Anyone has any ideas on how to read this from DB? I have been trying to make a sql processor to read this but without success. Thanks.

    Comment by assafn — 6/16/2006 @ 10:26 am

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress