-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
112 lines (93 loc) · 4.81 KB
/
run.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# 1. Download specgen
#rm -fr specgen_input
#git clone https://github.com/nsip/specgen_input.git
# 2. Empty target directories
rm -rf sifxml
rm -rf sifxml_tmp
rm -rf sifgraphql
mkdir -p sifxml
mkdir -p sifxml_tmp
mkdir -p sifgraphql
echo "" > sifgraphql/sif-schema.graphql
echo "package sifxml\n" > sifxml_tmp/examples.go
# 3. Extract all necessary information from specgen into flat files
containsElement () {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
xsltproc scripts/included_objects.xslt specgen_input/06_DataModel/Custom/DataModel-Custom-AU.xml | perl -ne 'next unless $_ =~ /\S/; next if $_ =~ /<\?/; s/^\s+//; s/\s+$//; print "./specgen_input/06_DataModel/Custom/" . $_ . "\n"' > objs.txt
IFS=$'\n' read -d '' -r -a objectarray < objs.txt
for filename in ./specgen_input/06_DataModel/Custom/Common/*.xml; do
if containsElement "$filename" "${objectarray[@]}" ; then
:
else
echo "Excluded:" $filename;
continue;
fi
if #[[ "$filename" == "./specgen_input/06_DataModel/Custom/Common/StudentScoreSet.xml" ]] ||
[[ "$filename" == "./specgen_input/06_DataModel/Custom/Common/PersonPrivacyObligation.xml" ]] ||
[[ "$filename" == "./specgen_input/06_DataModel/Custom/Common/ReportAuthorityInfo.xml" ]] ; then
continue
fi
xsltproc scripts/sifobject.xslt "$filename" | perl scripts/xslt_postprocess.pl | perl -s scripts/struct2go.pl -o > sifxml_tmp/$(basename "$filename" .xml).go
xsltproc scripts/sifobject.xslt "$filename" | perl scripts/xslt_postprocess.pl | perl scripts/struct2graphql.pl >> sifgraphql/sif-schema.graphql
done
for filename in ./specgen_input/06_DataModel/Custom/AU/*.xml; do
if containsElement "$filename" "${objectarray[@]}" ; then
:
else
echo "Excluded:" $filename;
continue;
fi
xsltproc scripts/sifobject.xslt "$filename" | perl scripts/xslt_postprocess.pl | perl -s scripts/struct2go.pl -o > sifxml_tmp/$(basename "$filename" .xml).go
xsltproc scripts/sifobject.xslt "$filename" | perl scripts/xslt_postprocess.pl | perl scripts/struct2graphql.pl >> sifgraphql/sif-schema.graphql
done
echo '<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns="http://sifassociation.org/SpecGen" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xhtml="http://www.w3.org/1999/xhtml" >' > data.xml
cat specgen_input/80_BackMatter/Generic-CommonTypes.xml >> data.xml
cat specgen_input/80_BackMatter/Custom/DataModel-CommonTypes-Custom.xml >> data.xml
echo '</root>' >> data.xml
xsltproc scripts/sifobject.xslt data.xml | perl scripts/xslt_postprocess.pl | perl scripts/struct2go.pl > sifxml_tmp/DataModel.go
echo "type String string\ntype Int int\ntype Float float64\ntype Bool bool" >> sifxml_tmp/DataModel.go
xsltproc scripts/sifobject.xslt data.xml | perl scripts/xslt_postprocess.pl | perl scripts/struct2graphql.pl >> sifgraphql/sif-schema.graphql
echo '<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns="http://sifassociation.org/SpecGen" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xhtml="http://www.w3.org/1999/xhtml" >' > codesets.xml
cat specgen_input/80_BackMatter/Custom/DataModel-CodeSets-Custom.xml >> codesets.xml
cat specgen_input/80_BackMatter/Custom/DataModel-ExternalCodeSets-Custom.xml >> codesets.xml
echo '</root>' >> codesets.xml
xsltproc scripts/sifobject.xslt codesets.xml | perl scripts/xslt_postprocess.pl | perl scripts/struct2go.pl > sifxml_tmp/Codesets.go
for filename in ./sifxml_tmp/*.go; do
cat "$filename" | perl scripts/struct2go2.pl > sifxml/$(basename "$filename")
done
cat sifxml_tmp/DataModel.go | perl -s scripts/struct2go2.pl -o > sifxml/DataModel.go
cat sifxml_tmp/[A-Z]*.go | perl -d scripts/goHelpers.pl > sifxml/Helpers.go
# 4. Examples
for filename in ./specgen_input/06_DataModel/Custom/Common/*.xml; do
if containsElement "$filename" "${objectarray[@]}" ; then
:
else
echo "Excluded:" $filename;
continue;
fi
if #[[ "$filename" == "./specgen_input/06_DataModel/Custom/Common/StudentScoreSet.xml" ]] ||
[[ "$filename" == "./specgen_input/06_DataModel/Custom/Common/PersonPrivacyObligation.xml" ]] ||
[[ "$filename" == "./specgen_input/06_DataModel/Custom/Common/ReportAuthorityInfo.xml" ]] ; then
continue
fi
perl scripts/sifexamples.pl "$filename" >> sifxml/examples.go
done
for filename in ./specgen_input/06_DataModel/Custom/AU/*.xml; do
if containsElement "$filename" "${objectarray[@]}" ; then
:
else
echo "Excluded:" $filename;
continue;
fi
#if [[ "$filename" == "./specgen_input/06_DataModel/Custom/Common/StudentScoreSet.xml" ]]; then
#continue
#fi
perl scripts/sifexamples.pl "$filename" >> sifxml/examples.go
done
cat sifxml/examples.go | perl scripts/siftest.pl > sifxml/sifxml_test.go
cp scripts/doc.go sifxml/doc.go