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