2020-02-27 07:54:50 -07:00
|
|
|
#!/bin/sh
|
|
|
|
# converts the <rules>.xml file to the old format <rules>.lst file
|
2020-02-27 12:03:43 -07:00
|
|
|
# Usage: xml2lst < filename.xml > filename.lst
|
2020-02-27 07:54:50 -07:00
|
|
|
|
2020-02-27 12:03:43 -07:00
|
|
|
var=0 com=0 nam=''
|
2020-02-27 07:54:50 -07:00
|
|
|
|
|
|
|
printf '! model\n'
|
2020-02-27 12:03:43 -07:00
|
|
|
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
|
2020-02-27 07:54:50 -07:00
|
|
|
|
|
|
|
printf '\n! layout\n'
|
2020-02-27 12:03:43 -07:00
|
|
|
while read -r l || [ "$l" ]; do case $l in
|
|
|
|
*'<variantList>'*) var=1;;
|
|
|
|
*'</variantList>'*) var=0;;
|
|
|
|
*'</layoutList>'*) break;;
|
|
|
|
|
2020-05-03 14:44:01 -06:00
|
|
|
*'<name>'*)
|
2020-02-27 12:03:43 -07:00
|
|
|
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%<*} ;;
|
|
|
|
|
2020-05-03 14:44:01 -06:00
|
|
|
*'<description>'*)
|
2020-02-27 12:03:43 -07:00
|
|
|
l=${l#*>}
|
|
|
|
|
|
|
|
[ "$com" -ne 0 ] || printf ' %-20s %s\n' "$n" "${l%<*}"
|
|
|
|
;;
|
|
|
|
esac; done
|