paperjam

Untitled

Jan 12th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. export enableDelayedExpansion
  4.  
  5. xmlint="C:\lib\libxml2-2.9.3\bin\xmllint.exe"
  6.  
  7. xml_file="${1}"
  8.  
  9. schema_file="${2}"
  10.  
  11. stderr_file="${3}"
  12.  
  13. temp_file="${3}"
  14.  
  15. xml_file_path="$(dirname ${xml_file})"
  16.  
  17. xml_file_name="$(basename ${xml_file})"
  18.  
  19. # :: XMLLINT_INDENT must be set to a tab character, make sure you use an editor that does not replace tab charcters with spaces
  20.  
  21. export XMLLINT_INDENT=$'\t'
  22.  
  23. cd "${xml_file_path}"
  24.  
  25. # :: formating xml file with line breaks and indents
  26.  
  27. "${xmlint}" "${xml_file_name}" --format --recover > "${temp_file}" && mv -f "${temp_file}" "${xml_file_name}"
  28.  
  29. # :: validating against schema
  30.  
  31. "${xmlint}" "${xml_file_name}" -schema "${schema_file}" -noout -stream 2> "${stderr_file}"
Advertisement
Add Comment
Please, Sign In to add comment