896d00
1,/
896d00
896d00
# on each new iso-code process the current one
896d00
\!\(<iso_3166_entry\|</iso_3166_entries>\)!{
896d00
    x
896d00
    s/^$//
896d00
    # we are on the first iso-code--nothing to process here
896d00
    t
896d00
    # process and write to output
896d00
    s/\s\+/ /g
896d00
    s/
896d00
    s!/\s*>!!
896d00
    # use '%' as a separator of parsed and unparsed input
896d00
    s/\(.*\)alpha_2_code="\([^"]\+\)"\(.*\)/\2 % \1 \3/
896d00
    s/\([^%]\+\)%\(.*\)alpha_3_code="\([^"]\+\)"\(.*\)/\1% \2 \4/
896d00
    #  clear subst. memory for the next t
896d00
    t clear
896d00
    :clear
896d00
    s/\([^%]\+\)%\(.*\)numeric_code="\([^"]\+\)"\(.*\)/\1% \2 \4/
896d00
    t name
896d00
    # no 3166 code--write xx
896d00
    s/%/\tXX %/
896d00
    :name
896d00
    s/\([^%]\+\)%\(.*\)name="\([^"]\+\)"\(.*\)/\1\t\3/
896d00
    s/ \t/\t/g
896d00
    p
896d00
    b
896d00
    :noout
896d00
}
896d00
896d00
H