summaryrefslogtreecommitdiffstats
path: root/test/w3c/convert-tests.sh
blob: f30f8cf62b9803ca7d23bf0e94bf60c5fa5f4e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash

#
# Convert all SCXML IRP tests from the W3C for specific datamodels
#

ME=`basename $0`
DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $DIR

TXMLS=`ls txml/*.txml`
TRANSFORM="java -jar /Users/sradomski/Developer/Applications/SaxonHE9-4-0-7J/saxon9he.jar"

# see http://saxon.sourceforge.net/saxon6.5.1/using-xsl.html
for TXML in $TXMLS
do
	echo -n "Processing $TXML for "
	TARGETFILE=`basename $TXML .txml`.scxml
	# echo -n "ecma " && $TRANSFORM $TXML confEcma.xsl -o:ecma/$TARGETFILE
	echo -n "namespace " && $TRANSFORM ecma/$TARGETFILE confNamespace.xsl -o:namespace/$TARGETFILE
	# echo -n "xpath " && $TRANSFORM $TXML confXPath.xsl -o:xpath/$TARGETFILE
	# echo -n "promela " && $TRANSFORM $TXML confPromela.xsl -o:promela/$TARGETFILE
	# echo -n "prolog " && $TRANSFORM $TXML confProlog.xsl -o:prolog/$TARGETFILE
	# echo -n "lua " && $TRANSFORM $TXML confLua.xsl -o:lua/$TARGETFILE
	echo
done

# make sure substitutions are idempotent!

# percent needs to be escaped in lua patterns
sed -i.orig 's/this%20is%20some%20content/this%%20is%%20some%%20content/g' ./lua/test520.scxml

# x-www-form-urlencode will not preserve the type and we default to string
sed -i.orig 's/Var1==2/tonumber(Var1)==2/g' ./lua/test567.scxml

# unnamespace embedded xml in namespace tests
sed -i.orig 's/scxml:book/book/g' ./namespace/test557.scxml
sed -i.orig 's/scxml:book/book/g' ./namespace/test561.scxml

cp txml/*.txt ecma/
cp txml/*.txt namespace/
cp txml/*.txt xpath/
cp txml/*.txt promela/
cp txml/*.txt prolog/
cp txml/*.txt lua/

find ./ecma -type f -exec grep -Ili 'datamodel="xpath"' {} \; |xargs rm -fv
find ./namespace -type f -exec grep -Ili 'datamodel="xpath"' {} \; |xargs rm -fv
find ./xpath -type f -exec grep -Ili 'datamodel="ecmascript"' {} \; |xargs rm -fv

find ./promela -type f -exec grep -Ili 'datamodel="xpath"' {} \; |xargs rm -fv
find ./promela -type f -exec grep -Ili 'datamodel="ecmascript"' {} \; |xargs rm -fv
find ./promela -type f -exec grep -Ili 'datamodel="null"' {} \; |xargs rm -fv

find ./prolog -type f -exec grep -Ili 'datamodel="xpath"' {} \; |xargs rm -fv
find ./prolog -type f -exec grep -Ili 'datamodel="ecmascript"' {} \; |xargs rm -fv
find ./prolog -type f -exec grep -Ili 'datamodel="null"' {} \; |xargs rm -fv

find ./lua -type f -exec grep -Ili 'datamodel="xpath"' {} \; |xargs rm -fv
find ./lua -type f -exec grep -Ili 'datamodel="ecmascript"' {} \; |xargs rm -fv
find ./lua -type f -exec grep -Ili 'datamodel="null"' {} \; |xargs rm -fv

# test436 is the null datamodel
mv ./ecma/test436.scxml ./null
rm ./namespace/test436.scxml
rm ./xpath/test436.scxml
rm ./promela/test436.scxml
rm ./prolog/test436.scxml
rm ./lua/test436.scxml

# format all SCXML files
SCXMLS=`find . -type f -name '*.scxml'`
for SCXML in $SCXMLS
do
	mv $SCXML $SCXML.unformatted.xml
	xmllint --format $SCXML.unformatted.xml > $SCXML
	rm $SCXML.unformatted.xml
done