From DLXS Documentation
1 #!/bin/sh
2
3 #$Id: validateeach.sh,v 1.1 2008/07/08 19:07:44 tburtonw Exp $#
4 #
5 #
6 # for each finding aid in $DATA_DIRECTORY
7 # calls fixdoctype.pl to remove the document declaration
8 # calls onsgmls to validate the finding aid against the ead2002 dtd
9 #
10 # If your finding aids include entitys/entityrefs you will want to use a custom
11 # DOCTYPE_DECLARATION file instead of the samplefa.ead2002.dcl
12 # see $DLXSROOT/prep/s/samplefa/samplefa.ead2002.entity.example.dcl for an example
13 #
14 BINDIR=$DLXSROOT/bin/f/findaid/
15
16 # Argument processing
17 #
18 USAGE="USAGE: $0 -d DATA_DIRECTORY -x XML_DECLARATION -t DOCTYPE_DECLARATION"
19
20 while getopts d:x:t: OPT
21 do
22 case $OPT in
23 d) if [ -d ${OPTARG} ]
24 then
25 DATADIR=${OPTARG}
26 else
27 echo "$0: Data directory: $OPTARG is not a directory." >&2
28 exit 1
29 fi
30 ;;
31 x) if [ -e ${OPTARG} ]
32 then
33 XMLDECL=${OPTARG}
34 else
35 echo "$0: xmldecl file: $OPTARG does not exist." >&2
36 exit 1
37 fi
38 ;;
39 t) if [ -e ${OPTARG} ]
40 then
41 SINGLEDOCTYPE=${OPTARG}
42 else
43 echo "$0: Doctype file $OPTARG does not exist." >&2
44 exit 1
45 fi
46 ;;
47
48 \?) echo "$USAGE" 1>&2
49 exit 1
50 ;;
51 esac
52 done
53 #---------------------------------------------------------------------
54
55
56 for file in ${DATADIR}*.xml
57 do
58
59 echo "working on $file"
60 ${BINDIR}fixdoctype.pl $file > $file.tmp
61 onsgmls -wxml -w no-explicit-sgml-decl -s -f $file.err ${XMLDECL} ${SINGLEDOCTYPE} $file.tmp
62 rm $file.tmp
63 done
64
65
66 find $DATADIR -type f -size 0 -prune -exec rm {} \;
67