| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | lint_xmlsscip-shell shell debian-edu-artwork 2.13.1-1 lint_xmls().() { |
| 4 | local xml_file_pattern=$1 |
| 5 | local xml_lint_summary=$2 |
| 6 | |
| 7 | if [scip-shell system . . `[`. "$#" -ne 2 ] ; then |
| 8 | echoscip-shell system . . echo. "$0: wrong number of arguments." |
| 9 | echoscip-shell system . . echo. "Expected:" |
| 10 | echoscip-shell system . . echo. " $0 xml_file_pattern summary_file_name" |
| 11 | return 255 |
| 12 | fi |
| 13 | |
| 14 | echoscip-shell system . . echo. "Running xmllint for pattern '${xml_file_pattern}'" |
| 15 | echoscip-shell system . . echo. "Current directory is '$(pwd)'" |
| 16 | echoscip-shell system . . echo. "Result will be stored in ${xml_lint_summary}" |
| 17 | echoscip-shell system . . echo. |
| 18 | |
| 19 | echoscip-shell system . . echo. "file,xmllint_status" > ${xml_lint_summary} |
| 20 | |
| 21 | local files_list=$(findscip-shell system . . find. . -name "${xml_file_pattern}") |
| 22 | local nb_files=$(echoscip-shell system . . echo. "${files_list}" | wcscip-shell system . . wc. -l) |
| 23 | local nb_ok=0 |
| 24 | local nb_errors=0 |
| 25 | |
| 26 | echoscip-shell system . . 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 | echoscip-shell system . . echo. "${xml_file},${xmllint_result}" >> ${xml_lint_summary} |
| 32 | if [scip-shell system . . `[`. ${xmllint_result} -eq 0 ] ; then |
| 33 | echoscip-shell system . . echo. "'${xml_file}' is OK" |
| 34 | ((nb_ok++)) |
| 35 | else |
| 36 | echoscip-shell system . . echo. "'${xml_file}' has errors" |
| 37 | ((nb_errors++)) |
| 38 | fi |
| 39 | done <<< "${files_list}" |
| 40 | |
| 41 | echoscip-shell system . . echo. "Results of xmllint for pattern '${xml_file_pattern}'" |
| 42 | echoscip-shell system . . echo. " Checked: ${nb_files}" |
| 43 | echoscip-shell system . . echo. " OK: ${nb_ok}" |
| 44 | echoscip-shell system . . echo. " Errors: ${nb_errors}" |
| 45 | |
| 46 | return ${nb_errors} |
| 47 | |
| 48 | } |