repo/xorg/xkeyboard-config/files/xml2lst

48 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# converts the <rules>.xml file to the old format <rules>.lst file
# Usage: xml2lst < filename.xml > filename.lst
var=0 com=0 nam=''
printf '! model\n'
while read -r l || [ "$l" ]; do case $l in
*'<name>'*) n=${l#*>} n=${n%<*};;
*'<description>'*) l=${l#*>}; printf ' %-15s %s\n' "$n" "${l%<*}" ;;
*'</modelList>'*) break
esac; done
printf '\n! layout\n'
while read -r l || [ "$l" ]; do case $l in
*'<variantList>'*) var=1;;
*'</variantList>'*) var=0;;
*'</layoutList>'*) break;;
*'<name>'*)
l="${l#*>}"
[ "$var" -eq 0 ] && ln=${l%<*} || n=${l%<*}
;;
*'<description>'*)
l=${l#*>}
case $var in
0) printf ' %-15s %s\n' "${ln}" "${l%<*}" ;;
*) nam="${nam%x} $(printf '%-15s %s: %s\nx' "$n" "$ln" "${l%<*}")"
esac
;;
esac; done
printf '\n! variant\n%s\n! option\n' "${nam%x}"
while read -r l || [ "$l" ]; do case $l in
*'-->'*) com=0;;
*'<!--'*) com=1;;
*'</optionList>'*) break;;
*'<name>'*) n=${l#*>} n=${n%<*} ;;
*'<description>'*)
l=${l#*>}
[ "$com" -ne 0 ] || printf ' %-20s %s\n' "$n" "${l%<*}"
;;
esac; done