How to Ensure you are validating XML! #224
philipbaileynar
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@Riverscapes/riverscape-project-curators you should all know how to validate XML by now. However, I want to bring to your attention that sometimes you think you are validating XML when in fact you are not. When this happens in Visual Studio Code you will get no error messages or red squiggles suggesting that your XML might be OK when in fact XML validation is turned off. Here's an example...
I was just reviewing a VBET business logic pull request where the automated GitHub XML validation was failing and preventing completion of the pull request. But upon review in Visual Studio Code there were no XML errors appearing. Here's the top of the VBET business logic XML:
Notice the error? See how the
Project
tag closing angle brace is before the attributes? These attributes tell the validator which XSD rules file to use. The invalid XML closing angle brace means that Visual Studio Code can no longer validate the XML. I could write any garbage in this VBET business logic XML and no errors would appear!How to Check that XML validation is turned on
Here's a dumb little trick to check that Visual Studio Code is turned on and working. Take a second and write a pair of invalid XML tags. If the red squiggles appear then you know validation is working. No red squiggles and validation is not working. Without this check you won't know whether the absence of errors is legitimate or because validation is turned off.
For example, I always use the word "Bernard" (for no other reasons than its ridiculous and completely off topic). Without validation, see the lack of red squiggles:
But when I fix the broken closing brace, suddenly validation works and I get the error:
Conclusion
Take a second... write a pair of invalid XML tags to confirm that XML validation is turned on. Just remember to delete the test tags before you commit and push ;-)
Beta Was this translation helpful? Give feedback.
All reactions