1 | #! /bin/sh |
---|
2 | # |
---|
3 | #+ |
---|
4 | # .. program:: checkmain.sh |
---|
5 | # |
---|
6 | # ============ |
---|
7 | # checkmain.sh |
---|
8 | # ============ |
---|
9 | # |
---|
10 | # SYNOPSIS |
---|
11 | # ======== |
---|
12 | # |
---|
13 | # :: |
---|
14 | # |
---|
15 | # $ checkmain.sh [--debug] -i filein |
---|
16 | # |
---|
17 | # DESCRIPTION |
---|
18 | # =========== |
---|
19 | # |
---|
20 | # .. option:: -i <filein> |
---|
21 | # |
---|
22 | # Check SUPERBIB requirements in main.xml **filein** XML/DocBook. |
---|
23 | # |
---|
24 | # project |
---|
25 | # Should be defined :samp:`//d:keyword[@xml:id='project']` |
---|
26 | # |
---|
27 | # Is used for ++ |
---|
28 | # title |
---|
29 | # Should be defined :samp:`d:article/d:title` |
---|
30 | # |
---|
31 | # Is used for ++ |
---|
32 | # homepage |
---|
33 | # Should be defined :samp:`//d:bibliosource[@xml:id='homepage']` |
---|
34 | # |
---|
35 | # Is used for ++ |
---|
36 | # contact |
---|
37 | # Should be defined :samp:`/d:article/d:info/d:authorgroup/d:author[1]/d:email` |
---|
38 | # |
---|
39 | # Is used by PHP pages to send emails. |
---|
40 | # |
---|
41 | # .. warning:: |
---|
42 | # |
---|
43 | # There is now check on email and homepage. |
---|
44 | # They **must** be real to avoid black holes of mails and 404 HTPP errors. |
---|
45 | # |
---|
46 | # EXAMPLES |
---|
47 | # ======== |
---|
48 | # |
---|
49 | # To check the SUPERBIB demo main file:: |
---|
50 | # |
---|
51 | # $ ./checkmain.sh -i data/maindemo1.xml |
---|
52 | # Title : superbib Demo1 |
---|
53 | # Project : superbib demo1 |
---|
54 | # HOME page : http://forge.ipsl.jussieu.fr/superbib/ |
---|
55 | # Contact : Francoise.Pinsard@locean-ipsl.upmc.fr |
---|
56 | # |
---|
57 | # To check the NEMO demo main file:: |
---|
58 | # |
---|
59 | # $ ./checkmain.sh -i data/mainnemo.xml |
---|
60 | # Title : NEMO survey |
---|
61 | # Project : NEMO |
---|
62 | # HOME page : http://www.nemo-ocean.eu/ |
---|
63 | # Contact : opatlod@locean-ipsl.upmc.fr |
---|
64 | # |
---|
65 | # SEE ALSO |
---|
66 | # ======== |
---|
67 | # |
---|
68 | # :ref:`using` |
---|
69 | # |
---|
70 | # :ref:`components_db.xsl` |
---|
71 | # :ref:`form_db.xsl` |
---|
72 | # :ref:`main_html.xsl` |
---|
73 | # :ref:`main_rest.xsl` |
---|
74 | # :ref:`superbib01_html.xsl` |
---|
75 | # :ref:`superbib01_rest.xsl` |
---|
76 | # :ref:`superbib01_xml.xsl` |
---|
77 | # :ref:`superbib02_html.xsl` |
---|
78 | # :ref:`superbib02_xml.xsl` |
---|
79 | # :ref:`superbib03_xml.xsl` |
---|
80 | # :ref:`superbibmany01_html.xsl` |
---|
81 | # :ref:`superbibmany01_xml.xsl` |
---|
82 | # :ref:`superbibmany02_html.xsl` |
---|
83 | # :ref:`superbibmany02_xml.xsl` |
---|
84 | # :ref:`template_db.xsl` |
---|
85 | # :ref:`user_db.xsl` |
---|
86 | # :ref:`user_html.xsl` |
---|
87 | # :ref:`user_rest.xsl` |
---|
88 | # |
---|
89 | # TODO |
---|
90 | # ==== |
---|
91 | # |
---|
92 | # improve description |
---|
93 | # |
---|
94 | # XML/Docbook compliant : pb with element form: Schemas validity error : Element '{http://www.w3.org/1999/xhtml}form': This element is not expected. |
---|
95 | # .. so as I do not know haox to get rid of this I comment this test (see XFORM and so one) |
---|
96 | # |
---|
97 | # check for news on DocBook realase (now 20110701 5.0) |
---|
98 | # |
---|
99 | # |
---|
100 | # EVOLUTIONS |
---|
101 | # ========== |
---|
102 | # |
---|
103 | # $URL$ |
---|
104 | # |
---|
105 | # $Id$ |
---|
106 | # |
---|
107 | # - fplod 20120227 |
---|
108 | # |
---|
109 | # * xmlstarlet vs xml |
---|
110 | # |
---|
111 | # - fplod 20110701T113247Z cratos.locean-ipsl.upmc.fr (Linux) |
---|
112 | # |
---|
113 | # * creation |
---|
114 | # |
---|
115 | #- |
---|
116 | system=$(uname) |
---|
117 | case "${system}" in |
---|
118 | AIX|IRIX64) |
---|
119 | echo "www : no specific posix checking" |
---|
120 | date_cmd=date |
---|
121 | xmlcmd=xml |
---|
122 | ;; |
---|
123 | Darwin) |
---|
124 | set -o posix |
---|
125 | date_cmd=gdate |
---|
126 | xmlcmd=xmlstarlet |
---|
127 | ;; |
---|
128 | Linux) |
---|
129 | set -o posix |
---|
130 | date_cmd=date |
---|
131 | xmlcmd=xml |
---|
132 | ;; |
---|
133 | *) |
---|
134 | set -o posix |
---|
135 | ;; |
---|
136 | esac |
---|
137 | unset system |
---|
138 | # |
---|
139 | set -u |
---|
140 | # |
---|
141 | LANG=POSIX |
---|
142 | # |
---|
143 | command=$(basename ${0}) |
---|
144 | # |
---|
145 | usage=" Usage : ${command} [--debug] -i filein " |
---|
146 | # |
---|
147 | hostname=$(hostname) |
---|
148 | # |
---|
149 | # default |
---|
150 | debug=0 |
---|
151 | # |
---|
152 | minargcount=2 |
---|
153 | if [ ${#} -lt ${minargcount} ] |
---|
154 | then |
---|
155 | echo "${command} : eee : not enought arguments" |
---|
156 | echo "${usage}" |
---|
157 | exit 1 |
---|
158 | fi |
---|
159 | # |
---|
160 | while [ ${#} -gt 0 ] |
---|
161 | do |
---|
162 | case ${1} in |
---|
163 | --debug) |
---|
164 | debug=1 |
---|
165 | ;; |
---|
166 | -i) |
---|
167 | filein=${2} |
---|
168 | shift |
---|
169 | ;; |
---|
170 | *) |
---|
171 | # anything else |
---|
172 | echo "${command} : eee : unknown option ${1}" |
---|
173 | echo "${command} : eee : ${usage}" |
---|
174 | exit 1 |
---|
175 | ;; |
---|
176 | esac |
---|
177 | # next flag |
---|
178 | shift |
---|
179 | done |
---|
180 | # |
---|
181 | # check parameters |
---|
182 | # |
---|
183 | # check for filein |
---|
184 | if [ ! -f ${filein} ] |
---|
185 | then |
---|
186 | echo "eee : ${filein} not found" |
---|
187 | exit 1 |
---|
188 | fi |
---|
189 | # |
---|
190 | # test if xml available |
---|
191 | tool=${xmlcmd} |
---|
192 | type ${tool} 1> /dev/null 2>&1 |
---|
193 | status=${?} |
---|
194 | if [ ${status} -ne 0 ] |
---|
195 | then |
---|
196 | echo "${command} : eee : ${tool} not found" |
---|
197 | exit 1 |
---|
198 | fi |
---|
199 | unset status |
---|
200 | unset tool |
---|
201 | # |
---|
202 | #++# check XML/DocBook conformity |
---|
203 | #++${xmlcmd} val --err \ |
---|
204 | #++--xsd http://www.docbook.org/xml/5.0/xsd/docbook.xsd \ |
---|
205 | #++${filein} |
---|
206 | #++status=${?} |
---|
207 | #++if [ ${status} -ne 0 ] |
---|
208 | #++then |
---|
209 | #++ echo "${command} : eee : ${filein} is not XML/DocBook compliant" |
---|
210 | #++ exit 1 |
---|
211 | #++fi |
---|
212 | #++unset status |
---|
213 | # |
---|
214 | # title |
---|
215 | xpath="d:article/d:title" |
---|
216 | title=$(${xmlcmd} sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein}) |
---|
217 | if [ "${title}" = "" ] |
---|
218 | then |
---|
219 | echo "${command} : www : title not defined" |
---|
220 | echo "${command} : www : fix ${xpath}" |
---|
221 | exit 1 |
---|
222 | else |
---|
223 | echo "Title : ${title}" |
---|
224 | fi |
---|
225 | unset title |
---|
226 | # |
---|
227 | # |
---|
228 | # project |
---|
229 | project_ok=0 |
---|
230 | xpath="//d:keyword[@xml:id='project']" |
---|
231 | project=$(${xmlcmd} sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein}) |
---|
232 | if [ "${project}" = "" ] |
---|
233 | then |
---|
234 | echo "${command} : www : project not defined" |
---|
235 | echo "${command} : www : fix ${xpath}" |
---|
236 | else |
---|
237 | echo "Project : ${project}" |
---|
238 | project_ok=1 |
---|
239 | fi |
---|
240 | unset project |
---|
241 | # |
---|
242 | # homepage |
---|
243 | homepage_ok=0 |
---|
244 | xpath="//d:bibliosource[@xml:id='homepage']" |
---|
245 | homepage=$(${xmlcmd} sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein}) |
---|
246 | if [ "${homepage}" = "" ] |
---|
247 | then |
---|
248 | echo "${command} : www : homepage not defined" |
---|
249 | echo "${command} : www : fix ${xpath}" |
---|
250 | else |
---|
251 | echo "HOME page : ${homepage}" |
---|
252 | homepage_ok=1 |
---|
253 | fi |
---|
254 | unset homepage |
---|
255 | # |
---|
256 | # contact |
---|
257 | contact_ok=0 |
---|
258 | xpath="/d:article/d:info/d:authorgroup/d:author[1]/d:email" |
---|
259 | contact=$(${xmlcmd} sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein}) |
---|
260 | if [ "${contact}" = "" ] |
---|
261 | then |
---|
262 | echo "${command} : www : contact not defined" |
---|
263 | echo "${command} : www : fix ${xpath}" |
---|
264 | else |
---|
265 | echo "Contact : ${contact}" |
---|
266 | contact_ok=1 |
---|
267 | fi |
---|
268 | unset contact |
---|
269 | # |
---|
270 | unset command |
---|
271 | unset hostname |
---|
272 | unset usage |
---|
273 | # |
---|
274 | # end |
---|
275 | #++set |
---|
276 | exit 0 |
---|