23 |
23 |
|
24 |
24 |
function map()
|
25 |
25 |
{
|
26 |
|
map="../../mappings/$src-$out_fmt.$table.csv"
|
27 |
|
if test -e "$map" -a -e "$in"; then
|
|
26 |
test -e "$in" || return 1
|
|
27 |
local ext="${in##*.}" # after last "."
|
|
28 |
for map in "../../mappings/$src-$out_fmt."$table".csv"; do
|
|
29 |
table="${map%.*}" # remove extension
|
|
30 |
table="${table##*.}" # after last "."
|
28 |
31 |
(
|
29 |
|
ext="${in##*.}" # after last "."
|
30 |
32 |
if test "$ext" == "sh"; then
|
31 |
33 |
trace . "$in"
|
32 |
34 |
(. "$in"; "$1")
|
... | ... | |
35 |
37 |
"$1" <"$in"
|
36 |
38 |
fi
|
37 |
39 |
) || exit # abort tester
|
38 |
|
fi
|
|
40 |
done
|
39 |
41 |
}
|
40 |
42 |
|
41 |
43 |
function toXml()
|
42 |
44 |
{
|
43 |
|
local out="output/$stem.$out_fmt${method+.$method}.xml"
|
44 |
|
local accepted="accepted_output/$stem.$out_fmt.xml"
|
|
45 |
local stem="$orig_src.$table.$out_fmt"
|
|
46 |
local out="output/$stem${method+.$method}.xml"
|
|
47 |
local accepted="accepted_output/$stem.xml"
|
45 |
48 |
(
|
46 |
49 |
set -x
|
47 |
50 |
../map "$map" >"$out" || exit
|
... | ... | |
56 |
59 |
|
57 |
60 |
for in in input/*; do
|
58 |
61 |
stem="$(basename -- "${in%.*}")" # remove extension and dir
|
59 |
|
src="${stem%.*}" # before last "."
|
60 |
|
table="${stem##*.}" # after last "."
|
|
62 |
ext="${in##*.}" # after last "."
|
|
63 |
src="${stem%.*}" # before last ".", if any
|
|
64 |
orig_src="$src"
|
|
65 |
if test "$ext" == "sh"; then table="*" # use all tables with a mapping
|
|
66 |
else table="${stem##*.}" # after last "."
|
|
67 |
fi
|
61 |
68 |
|
62 |
69 |
for out_fmt in VegX VegBank; do map toXml; done # source to XML
|
63 |
70 |
out_fmt=VegBank
|
64 |
71 |
# VegX to VegBank
|
65 |
|
(src=VegX in="output/$stem.$src.xml" method=via_$src; map toXml) || exit
|
|
72 |
(
|
|
73 |
src=VegX method=via_$src
|
|
74 |
for in in "output/$orig_src."$table".$src.xml"; do
|
|
75 |
table="${in#*.}" # after first "."
|
|
76 |
table="${table%%.*}" # before second "."
|
|
77 |
map toXml
|
|
78 |
done
|
|
79 |
) || exit
|
66 |
80 |
map toDb # source to VegBank db
|
67 |
81 |
done
|
test/map: Process all tables for a given DB (.sh) input