Last change
on this file since 32311 was 28383, checked in by ak19, 11 years ago |
Added a bash script equivalent to the batch script added yesterday. Updated the Readme file and minor changes to the batch file too.
|
-
Property svn:executable
set to
*
|
File size:
1.6 KB
|
Line | |
---|
1 | #!/bin/bash
|
---|
2 |
|
---|
3 | function usage () {
|
---|
4 | echo ""
|
---|
5 | echo "Run as $0 <xsd file> <namespace> <setname (mds file name)>"
|
---|
6 | echo "E.g. xsd_to_mds.bat C:\<full-path>\CDWALite-xsd-public-v1-1.xsd cdwalite CDWALite"
|
---|
7 | echo ""
|
---|
8 | }
|
---|
9 |
|
---|
10 | # Check for 3 cmd line args
|
---|
11 | if [ -z "$3" ]; then
|
---|
12 | usage
|
---|
13 | fi
|
---|
14 |
|
---|
15 | # xsd input file and setName of mds file for output
|
---|
16 | xsd=$1
|
---|
17 | mds=$2
|
---|
18 |
|
---|
19 | if [ ! -f "$xsd" ]; then
|
---|
20 | echo "XSD file $xsd does not exist."
|
---|
21 | exit -1
|
---|
22 | fi
|
---|
23 |
|
---|
24 | if [ "x$GSDLHOME" = "x" ]; then
|
---|
25 | echo "No GSDLHOME set. Source the (gs3-)setup.(ba)sh file in your Greenstone before running this script."
|
---|
26 | exit -1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | outputdir=
|
---|
30 | if [ "x$GSDL3SRCHOME" != "x" ]; then
|
---|
31 | outputdir=$GSDL3SRCHOME
|
---|
32 | else
|
---|
33 | outputdir=$GSDLHOME
|
---|
34 | fi
|
---|
35 | outputfile=$outputdir/gli/metadata/$mds.mds
|
---|
36 | xsl=$outputdir/gli/classes/xml/xsd-to-mds.xsl
|
---|
37 |
|
---|
38 | if [ ! -f "$xsl" ]; then
|
---|
39 | echo "XSLT file $xsl can't be found."
|
---|
40 | exit -1
|
---|
41 | fi
|
---|
42 |
|
---|
43 | # See internal wiki page Writing_XSL#Running_ApplyXSLT_to_apply_an_XSLT_file_from_the_command_line
|
---|
44 | # Bash doesn't like quotes (escaped quotes) around _any_ of the file paths below.
|
---|
45 | mycmd="java -cp $GSDLHOME/bin/java/xalan.jar:$GSDLHOME/bin/java/ApplyXSLT.jar:$GSDLHOME/bin/java/. org.nzdl.gsdl.ApplyXSLT -t $xsl -x $xsd -o $outputfile"
|
---|
46 |
|
---|
47 |
|
---|
48 | # Call the command
|
---|
49 | $mycmd
|
---|
50 | status=$?
|
---|
51 |
|
---|
52 | # http://stackoverflow.com/questions/11079017/operations-on-boolean-variables
|
---|
53 | if [ $status != 0 ]; then
|
---|
54 | echo "*** Failed running: $mycmd"
|
---|
55 | echo "Return status: $status"
|
---|
56 | exit -1
|
---|
57 | elif [ ! -e "$outputfile" ]; then
|
---|
58 | echo "**** XSLT transform failed: the file $outputfile was not generated. Ran command:"
|
---|
59 | echo "$mycmd"
|
---|
60 | exit -1
|
---|
61 | else
|
---|
62 | echo "The file $outputfile has been generated."
|
---|
63 | fi
|
---|
64 | echo ""
|
---|
Note:
See
TracBrowser
for help on using the repository browser.