1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-21 08:45:04 -05:00

for #1235: variable casing to conform to convention

This commit is contained in:
Guus der Kinderen 2022-11-06 09:45:33 +01:00
parent f1197f143a
commit 3f6f199159

View File

@ -14,90 +14,90 @@
set -euo pipefail
VALIDATION_RESULT=0
validation_result=0
# 1. Check DTD conformance against xep.dtd
XEP_DTD="xep.dtd"
if xmllint --noout --dtdvalid "$XEP_DTD" "$1"
xep_dtd="xep.dtd"
if xmllint --noout --dtdvalid "$xep_dtd" "$1"
then
echo "[PASS] DTD conformance against xep.dtd"
else
echo "[FAIL] DTD conformance against xep.dtd"
VALIDATION_RESULT=1;
validation_result=1;
fi
FILE_NAME=$(basename -- "$1")
HEADER_NUMBER=$(xmllint --xpath '/xep/header/number/text()' --nowarning --dtdvalid "$XEP_DTD" "$1")
HEADER_STATUS=$(xmllint --xpath '/xep/header/status/text()' --nowarning --dtdvalid "$XEP_DTD" "$1")
HEADER_TYPE=$(xmllint --xpath '/xep/header/type/text()' --nowarning --dtdvalid "$XEP_DTD" "$1")
HEADER_APPROVER=$(xmllint --xpath '/xep/header/approver/text()' --nowarning --dtdvalid "$XEP_DTD" "$1")
file_name=$(basename -- "$1")
header_number=$(xmllint --xpath '/xep/header/number/text()' --nowarning --dtdvalid "$xep_dtd" "$1")
header_status=$(xmllint --xpath '/xep/header/status/text()' --nowarning --dtdvalid "$xep_dtd" "$1")
header_type=$(xmllint --xpath '/xep/header/type/text()' --nowarning --dtdvalid "$xep_dtd" "$1")
header_approver=$(xmllint --xpath '/xep/header/approver/text()' --nowarning --dtdvalid "$xep_dtd" "$1")
if echo "$FILE_NAME" | grep -Eq "^xep-[0-9]{4}.xml$"
if echo "$file_name" | grep -Eq "^xep-[0-9]{4}.xml$"
then
echo "[INFO] The filename ('$FILE_NAME') matches 'xep-[0-9]{4}.xml'."
echo "[INFO] The filename ('$file_name') matches 'xep-[0-9]{4}.xml'."
# 2. If the filename matches xep-[0-9]{4}.xml, check:
# 2.1 that the number in the filename equals /xep/header/number (XPath)
if [ "$FILE_NAME" = "xep-$HEADER_NUMBER.xml" ]
if [ "$file_name" = "xep-$header_number.xml" ]
then
echo "[PASS] The number in the filename ('$FILE_NAME') equals XPATH value /xep/header/number/text() ('$HEADER_NUMBER')."
echo "[PASS] The number in the filename ('$file_name') equals XPATH value /xep/header/number/text() ('$header_number')."
else
echo "[FAIL] The number in the filename ('$FILE_NAME') does not equals XPATH value /xep/header/number/text() ('$HEADER_NUMBER') (but should)."
VALIDATION_RESULT=1;
echo "[FAIL] The number in the filename ('$file_name') does not equals XPATH value /xep/header/number/text() ('$header_number') (but should)."
validation_result=1;
fi
else
echo "[INFO] The filename ('$FILE_NAME') does not match 'xep-[0-9]{4}.xml'."
echo "[INFO] The filename ('$file_name') does not match 'xep-[0-9]{4}.xml'."
# 3. If the filename does not match xep-[0-9]{4}.xml, check:
# 3.1 That the /xep/header/status/text() (XPath) is ProtoXEP
if [ "$HEADER_STATUS" = "ProtoXEP" ]
if [ "$header_status" = "ProtoXEP" ]
then
echo "[PASS] XPATH value /xep/header/status/text() ('$HEADER_STATUS') equals 'ProtoXEP'."
echo "[PASS] XPATH value /xep/header/status/text() ('$header_status') equals 'ProtoXEP'."
else
echo "[FAIL] XPATH value /xep/header/status/text() ('$HEADER_STATUS') does not equal 'ProtoXEP' (but should)."
VALIDATION_RESULT=1;
echo "[FAIL] XPATH value /xep/header/status/text() ('$header_status') does not equal 'ProtoXEP' (but should)."
validation_result=1;
fi
# 3.2 That the /xep/header/number/text() (XPath) is literally XXXX
if [ "$HEADER_NUMBER" = "XXXX" ]
if [ "$header_number" = "XXXX" ]
then
echo "[PASS] XPATH value /xep/header/number/text() ('$HEADER_STATUS') equals 'XXXX'."
echo "[PASS] XPATH value /xep/header/number/text() ('$header_status') equals 'XXXX'."
else
echo "[FAIL] XPATH value /xep/header/nimber/text() ('$HEADER_STATUS') does not equal 'XXXX' (but should)."
VALIDATION_RESULT=1;
echo "[FAIL] XPATH value /xep/header/nimber/text() ('$header_status') does not equal 'XXXX' (but should)."
validation_result=1;
fi
# 3.3 That the name does not start with xep-[0-9]
if echo "$FILE_NAME" | grep -Eq "^xep-[0-9].*$"
if echo "$file_name" | grep -Eq "^xep-[0-9].*$"
then
echo "[FAIL] The filename ('$FILE_NAME') starts with 'xep-[0-9]' (but should not)."
VALIDATION_RESULT=1;
echo "[FAIL] The filename ('$file_name') starts with 'xep-[0-9]' (but should not)."
validation_result=1;
else
echo "[PASS] The filename ('$FILE_NAME') does not start with 'xep-[0-9]'."
echo "[PASS] The filename ('$file_name') does not start with 'xep-[0-9]'."
fi
fi
# 4. Check that /xep/header/status/text() (XPath) is a defined status (see tools/xeplib.py for an enum)
case $HEADER_STATUS in
case $header_status in
ProtoXEP | Experimental | Proposed | Draft | Active | Final | Retracted | Obsolete | Deferred | Rejected | Deprecated )
echo "[PASS] XPATH value /xep/header/status/text() ('$HEADER_STATUS') equals a defined status."
echo "[PASS] XPATH value /xep/header/status/text() ('$header_status') equals a defined status."
;;
*)
echo "[FAIL] XPATH value /xep/header/status/text() ('$HEADER_STATUS') does not equals a defined status (but should)."
VALIDATION_RESULT=1;
echo "[FAIL] XPATH value /xep/header/status/text() ('$header_status') does not equals a defined status (but should)."
validation_result=1;
;;
esac
# 5. Check that /xep/header/type/text() (XPath) is defined in XEP-0001
# If the XEP number is less than 400, also accept some legacy values. To find which, see which you encounter in the XEP numbers below 400 :-).
echo "[INFO] implementation of validation of XPATH value /xep/header/type/text() ('$HEADER_TYPE') is pending!"
echo "[INFO] implementation of validation of XPATH value /xep/header/type/text() ('$header_type') is pending!"
# 6. Check that /xep/header/approver/text() (XPath) is either Board or Council
case $HEADER_APPROVER in
case $header_approver in
Board | Council )
echo "[PASS] XPATH value /xep/header/approver/text() ('$HEADER_APPROVER') equals either 'Board' or 'Council'."
echo "[PASS] XPATH value /xep/header/approver/text() ('$header_approver') equals either 'Board' or 'Council'."
;;
*)
echo "[FAIL] XPATH value /xep/header/approver/text() ('$HEADER_APPROVER') does not equals 'Board' or 'Council' (but should)."
VALIDATION_RESULT=1;
echo "[FAIL] XPATH value /xep/header/approver/text() ('$header_approver') does not equals 'Board' or 'Council' (but should)."
validation_result=1;
;;
esac
@ -105,14 +105,14 @@ esac
echo "[INFO] implementation of validation version numbers in the revision blocks is pending!"
# 8. If the approver (see above) is Board, enforce that /xep/header/type is not Standards Track.
if [ "$HEADER_APPROVER" = "Board" ]
if [ "$header_approver" = "Board" ]
then
if [ "$HEADER_TYPE" = "Standards Track" ]
if [ "$header_type" = "Standards Track" ]
then
echo "[FAIL] XPATH value /xep/header/approver/text() ('$HEADER_APPROVER') is 'Board' but XPATH value /xep/header/type/text() is 'Standards Track' (it should not be)."
VALIDATION_RESULT=1;
echo "[FAIL] XPATH value /xep/header/approver/text() ('$header_approver') is 'Board' but XPATH value /xep/header/type/text() is 'Standards Track' (it should not be)."
validation_result=1;
else
echo "[PASS] XPATH value /xep/header/approver/text() ('$HEADER_APPROVER') is 'Board' and XPATH value /xep/header/type/text() is not 'Standards Track'."
echo "[PASS] XPATH value /xep/header/approver/text() ('$header_approver') is 'Board' and XPATH value /xep/header/type/text() is not 'Standards Track'."
fi
fi
@ -123,10 +123,10 @@ echo "[INFO] implementation of xep.xsl XML stylesheet usage is pending!"
echo "[INFO] implementation of inclusion of correct legal notice is pending!"
echo ""
if [ $VALIDATION_RESULT = 0 ]
if [ $validation_result = 0 ]
then
echo "No issues found (but not all checks are implemented).";
else
echo "Issues found!"
fi
exit $VALIDATION_RESULT
exit $validation_result