Lint and Cleanup
XML Well-Formed vs Valid Guide
Understand the difference between well-formed XML syntax and schema-valid XML before debugging integrations, feeds or SOAP messages. This reference is written for developers who need practical validation behavior, reviewable rules and safe examples rather than copied snippets with no explanation.
Recommended workflow
| Step | Why it matters |
|---|---|
| Parse first | A schema validator cannot help until the document is readable XML. |
| Validate second | Only after parsing should you check XSD-required elements, attributes and types. |
| Compare contracts | Integration bugs often come from using an old schema or undocumented partner change. |
| Document unsupported cases | Record which optional fields your system intentionally ignores. |
Starter snippet
Well-formed: parser can read the XML
Valid: XML also satisfies DTD or XSD rulesReview checks
- Run a no-schema lint before an XSD validation.
- Keep example payloads synthetic and minimal.
- Version schemas next to integration code.
- Link validation failures to the owning contract or partner spec.
Common mistakes
- Calling XML valid just because it opens in a formatter.
- Assuming pretty printed XML means contract compliance.
- Mixing partner-specific rules into a generic XML cleanup function.
Validation should help users correct input while protecting systems from bad data. Keep syntax checks, product policy, security review and deliverability checks separate.
Related Formalint references
Continue with XML Lint Error, Xml Schema Xsd Guide, Api Request Body Validation Guide.