mirror of
https://codeberg.org/kiss-community/repo
synced 2024-08-22 22:16:19 +00:00
110 lines
2.8 KiB
Plaintext
110 lines
2.8 KiB
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
# converts the <rules>.xml file to the old format <rules>.lst file
|
||
|
#
|
||
|
# Usage:
|
||
|
#
|
||
|
# sh xml2lst.sh < filename.xml > filename.lst
|
||
|
#
|
||
|
# author Ivan Pascal
|
||
|
|
||
|
configitem=0
|
||
|
modellist=0
|
||
|
layout=0
|
||
|
configitem=0
|
||
|
variant=0
|
||
|
comment=0
|
||
|
|
||
|
printf '! model\n'
|
||
|
|
||
|
while read -r line || [ "$line" ]; do
|
||
|
case $line in
|
||
|
*'<configItem>'*) configitem=1 ;;
|
||
|
*'</configItem>'*) configitem=0 ;;
|
||
|
*'<modelList>'*) modellist=1 ;;
|
||
|
*'</modelList>'*) break ;;
|
||
|
|
||
|
*'<name>'*)
|
||
|
name=${line##*<name>}
|
||
|
name=${name%%</name>*}
|
||
|
;;
|
||
|
|
||
|
*'<description>'*)
|
||
|
desc=${line##*<description>}
|
||
|
desc=${desc%%</description>*}
|
||
|
|
||
|
[ "$configitem" -eq 0 ] || [ "$modellist" -eq 0 ] ||
|
||
|
printf ' %-15s %s\n' "$name" "$desc"
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
printf '\n! layout\n'
|
||
|
|
||
|
while read -r line || [ "$line" ]; do
|
||
|
case $line in
|
||
|
*'<layoutList>'*|*'<layout>'*) layout=1 ;;
|
||
|
*'</layout>'*) layout=0 ;;
|
||
|
*'<configItem>'*) configitem=1 ;;
|
||
|
*'</configItem>'*) configitem=0 ;;
|
||
|
*'<variantList>'*|*'<variant>'*) variant=1 ;;
|
||
|
*'</variantList>'*|*'</variant>'*) variant=0 ;;
|
||
|
*'</layoutList>'*) break ;;
|
||
|
esac
|
||
|
|
||
|
if [ "$layout" -ne 0 ]; then
|
||
|
if [ "${variant}" -ne 0 ]; then
|
||
|
case $line in
|
||
|
*'<name>'*)
|
||
|
name=${line##*<name>}
|
||
|
name=${name%%</name>*}
|
||
|
;;
|
||
|
|
||
|
*'<description>'*)
|
||
|
line="$lname: ${line##*<description>}"
|
||
|
line=${line%%</description>*}
|
||
|
names="$names $(printf '%-15s %s' "$name" "$line")
|
||
|
"
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
elif [ "$configitem" -ne 0 ]; then
|
||
|
case $line in
|
||
|
*'<name>'*)
|
||
|
lname=${line##*<name>}
|
||
|
lname=${lname%%</name>*}
|
||
|
;;
|
||
|
|
||
|
*'<description>'*)
|
||
|
line=${line##*<description>}
|
||
|
line=${line%%</description>*}
|
||
|
printf ' %-15s %s\n' "$lname" "$line"
|
||
|
;;
|
||
|
esac
|
||
|
fi
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
printf '\n! variant\n%s\n! option\n' "$names"
|
||
|
|
||
|
while read -r line || [ "$line" ]; do
|
||
|
case $line in
|
||
|
*'-->'*) comment=0;;
|
||
|
*'<!--'*) comment=1;;
|
||
|
*'</optionList>'*) break;;
|
||
|
|
||
|
*'<name>'*)
|
||
|
name=${line##*<name>}
|
||
|
name=${name%%</name>*}
|
||
|
;;
|
||
|
|
||
|
*'<description>'*)
|
||
|
line=${line##*<description>}
|
||
|
line=${line%%</description>*}
|
||
|
|
||
|
[ "$comment" -ne 0 ] ||
|
||
|
printf ' %-20s %s\n' "$name" "$line"
|
||
|
;;
|
||
|
esac
|
||
|
done
|