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