Debian Codegraph @

debian/tests/xmllint-functions

raw symbols SCIP
1 #!/bin/bash
2
3 lint_xmls() {
4 local xml_file_pattern=$1
5 local xml_lint_summary=$2
6
7 if [ "$#" -ne 2 ] ; then
8 echo "$0: wrong number of arguments."
9 echo "Expected:"
10 echo " $0 xml_file_pattern summary_file_name"
11 return 255
12 fi
13
14 echo "Running xmllint for pattern '${xml_file_pattern}'"
15 echo "Current directory is '$(pwd)'"
16 echo "Result will be stored in ${xml_lint_summary}"
17 echo
18
19 echo "file,xmllint_status" > ${xml_lint_summary}
20
21 local files_list=$(find . -name "${xml_file_pattern}")
22 local nb_files=$(echo "${files_list}" | wc -l)
23 local nb_ok=0
24 local nb_errors=0
25
26 echo "${nb_files} files will be checked"
27
28 while IFS= read -d $'\n' -r xml_file ; do
29 xmllint --noout ${xml_file}
30 local xmllint_result=$?
31 echo "${xml_file},${xmllint_result}" >> ${xml_lint_summary}
32 if [ ${xmllint_result} -eq 0 ] ; then
33 echo "'${xml_file}' is OK"
34 ((nb_ok++))
35 else
36 echo "'${xml_file}' has errors"
37 ((nb_errors++))
38 fi
39 done <<< "${files_list}"
40
41 echo "Results of xmllint for pattern '${xml_file_pattern}'"
42 echo " Checked: ${nb_files}"
43 echo " OK: ${nb_ok}"
44 echo " Errors: ${nb_errors}"
45
46 return ${nb_errors}
47
48 }