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