User:Scsbot/formtools/formsetup

tag=$1 file=$2

tf=tf$$

rm="/bin/rm -f"

td=td$tag

xmlsed -t $file &gt; $tf

forms="`grep '/form$' $tf`" nf=`echo "$forms" | wc -l`

if test $nf -lt 1 then echo "unexpected (no forms)" &gt;&amp;2 exit 1 fi

mkdir $td || exit 1

for x in `echo "$forms" | column 1` do formname="`xmlsed -x $file \\#$x/@name`" formid="`xmlsed -x $file \\#$x/@id`"

echo "$x	$formid	$formname" &gt;&gt; $td/.toc

mkdir $td/$x

xmlsed -x $file \#$x/@action &gt; $td/$x/.action xmlsed -x $file \#$x/@method &gt; $td/$x/.method

pat=`echo $x | sed 's/\./\\\\./g'`

for y in `grep "^$pat\\..*input$" $tf | column 1` do	name="`xmlsed -x $file \\#$y/@name`" type="`xmlsed -x $file \\#$y/@type`" value="`xmlsed -x $file \\#$y/@value`"

echo "$value" &gt; $td/$x/$name

echo "$name	$type" &gt;&gt; $td/$x/.toc done

for y in `grep "^$pat\\..*/textarea$" $tf | column 1` do	name="`xmlsed -x $file \\#$y/@name`" type=".textarea"

xmlsed -x $file \#$y &gt; $td/$x/$name

echo "$name	$type" &gt;&gt; $td/$x/.toc done done

$rm $tf

exit 0