Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify formatting of XML and XSD files #114

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .travis/xmllint-check.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
#!/bin/bash
/usr/bin/find . -type f \( -name "*.xsd" -or -name "*.xml" \) -print0 | while read -r -d $'\0' filename; do XMLLINT_INDENT=$'\t' xmllint --encode UTF-8 --pretty 1 "${filename}" > "${filename}.pretty"; mv "${filename}.pretty" "${filename}"; grep -i -v "xmlspy" "${filename}" > "${filename}.tmp" && mv "${filename}.tmp" "${filename}"; done;
echo "finished formatting"
# The -e flag causes the script to exit as soon as one command returns a non-zero exit code
set -e

echo "Formatting XSD and XML files"

PARSING_ERROR=0
while IFS= read -r -d $'\0' filename; do
if XMLLINT_INDENT=$'\t' xmllint --encode UTF-8 --pretty 1 "${filename}" >"${filename}.pretty"; then
grep -i -v "xmlspy" "${filename}.pretty" >"${filename}"
else
PARSING_ERROR=$?
echo -e "\033[0;31mParsing of file '${filename}' failed\033[0m"
fi
rm "${filename}.pretty"
done < <(/usr/bin/find . -type f \( -name "*.xsd" -or -name "*.xml" \) -print0)

if [ ${PARSING_ERROR} -ne 0 ]; then
exit ${PARSING_ERROR}
fi
echo -e '\033[0;32mFinished formatting XSD and XML files\033[0m'

# xmllint --noout --schema OJP.xsd examples/subdirectory1/*xml examples/subdirectory2/*xml