Skip to content

Formatting of Code

haeckerbaer edited this page Feb 25, 2020 · 5 revisions

Xmllint

To harmonize the XML, XSD and WSDL-files they should always be treated with xmllint before integrating them. The following code shows an excerpt from a shell script doing exactly that:

#!/bin/bash /usr/bin/find . -name "*.xsd" -type f | while read i; do XMLLINT_INDENT=" " xmllint --pretty 1 "$i" > "$i.pretty"; mv "$i.pretty" "$i"; done; /usr/bin/find . -name "*.xml" -type f | while read i; do XMLLINT_INDENT=" " xmllint --pretty 1 "$i" > "$i.pretty"; mv "$i.pretty" "$i"; done; /usr/bin/find . -name "*.wsdl" -type f | while read i; do XMLLINT_INDENT=" " xmllint --pretty 1 "$i" > "$i.pretty"; mv "$i.pretty" "$i"; done; echo "finished formatting"

The script is executed with bash xmllint-check.sh

Bash can be used on a windows machine via Cygwin (see link below).

Resources

TravisCI

The formatting with xmllint as shown above doesn't need to be done by the contributors. Changes to the SIRI-CEN repo are automatically corrected (or reformatted respectively) by TravisCI. If contributors still want to utilize xmllint or want to check/validate the changes themselves, they can use the xmllint-check script provided in the subfolder /.travis.

Clone this wiki locally