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