-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbatch-ezservice.sh
123 lines (107 loc) · 2.94 KB
/
batch-ezservice.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
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# EZService batch processing
#
# Stephen Bayliss 2011-05-09
#
# Dependencies:
# - EZService
# - Environment variable EZSERVICE must point to the EZService folder
#
# Description
#
# This script runs a set of related EZService input files through EZService to generate
# SDef and SDep FOXML files
#
# Usage
#
# Copy this script to the base directory of your EZDef and EZDep input files.
# Change to that directory, and run:
#
# ../batch-ezservice.sh
#
# The following directory structure (relative to this script) is required:
#
# ./EZDef - EZDef xml input files
# ./EZDep - EZDep xml input files
# ./SDef - SDef FOXML output files
# ./SDep - SDep FOXML output filles
#
# File naming:
# - EZDef input files must end in .xml
# - EZDep input files must be named the same as the EZDep input files, but with a "-[cmodel]" suffix in the name
# -- this allows for multiple EZDeps for each EZDef, differentiated by the content model name
#
# eg
# EZDef/myservice.xml
# EZDep/myservice-image.xml
# EZDep/myservice-document.xml
#
# output files are named the same as the corresponding input files
here=$(dirname $0)
# check for EZService
if [[ "$EZSERVICE" == "" ]]
then
echo "Error: Please set (and export) environment variable EZSERVICE, pointing at your EZService installation folder"
exit 1
fi
ezdefxsl="$EZSERVICE/ezdef.xsl"
ezdepxsl="$EZSERVICE/ezdep.xsl"
saxon="$EZSERVICE/lib/saxon9.jar"
dependencies="true"
if [[ ! -e "$ezdefxsl" ]]
then
echo "Error: could not locate $ezdefxsl - check EZSERVICE is set correctly"
dependencies="false"
fi
if [[ ! -e "$ezdepxsl" ]]
then
echo "Error: could not locate $ezdepxsl - check EZSERVICE is set correctly"
dependencies="false"
fi
if [[ ! -e "$saxon" ]]
then
echo "Error: could not locate $saxon - check EZSERVICE is set correctly"
dependencies="false"
fi
if [[ ! "$dependencies" == "true" ]]
then
exit 1
fi
# output directories
if [[ ! -d SDef ]]
then
mkdir SDef
fi
if [[ ! -d SDep ]]
then
mkdir SDep
fi
# Iterate each EZDef
for file in EZDef/*.xml
do
# generate input and output filenames
base=`basename $file`
ezdef="$here/EZDef/$base"
sdef="$here/SDef/$base"
# Corresponding EZDep pattern match
ezdeppattern="$here/EZDep/${base/%.xml/-*.xml}"
# do the EZDef
echo "Creating SDef from EZDef $base"
"$JAVA_HOME/bin/java" -jar $EZSERVICE/lib/saxon9.jar -xsl:$EZSERVICE/ezdef.xsl -versionmsg:off -s:$ezdef > $sdef
for file2 in `ls $ezdeppattern`
do
base=`basename $file2`
ezdep="$here/EZDep/$base"
sdep="$here/SDep/$base"
# the stylesheet additional input needs the full path to the ezdef input
ezdeffull=$(pwd)/$ezdef
# hack for cygwin
if [[ "$OSTYPE" == "cygwin" ]]
then
ezdeffull=`cygpath -m $ezdeffull`
fi
# do the EZDep
echo "...creating corresponding SDep from EZDep $base"
"$JAVA_HOME/bin/java" -jar $EZSERVICE/lib/saxon9.jar -xsl:$EZSERVICE/ezdep.xsl -versionmsg:off -s:$ezdep ezdef=$ezdeffull > $sdep
done
done