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