XML Schema Validation: A Practical Guide for Software Testers
Learn how tools like Notepad++, VS Code, Oxygen XML Editor, Java, and Python (lxml) help validate XML files against XSD schemas and identify errors in banking and ISO 20022 payment messages.
✍️ Translate this blog into Hindi, Tamil or Telugu

XML Schema Validation: A Practical Learning Guide for Payment Testers
Imagine receiving an XML payment message from another banking application.
The file opens successfully. The payment reference is available, the amount is populated, and the debtor and creditor information appears to be present.
Everything looks fine.
🛍️✨ From the author · ByteStorePayment Testing Masterclass, API, XML and end-to-end testing. β 1,000 Questions & AnswersβΉ2,300View offer →But when the receiving application tries to validate the message, it returns an error.
What could have gone wrong?
Perhaps a mandatory element is missing. Maybe an amount contains an incorrect data type, or two XML elements appear in the wrong order.
This is one of the reasons I wanted to understand XML Schema Validation.
When working with banking and payment applications, XML is an important format for exchanging structured information. Understanding how an XML document is checked against an XSD can help software testers identify problems before messages move further into a processing workflow.
I'm currently exploring XML and XSD fundamentals. In this article, I want to explain what I am learning through simple examples, practical testing scenarios and banking payment use cases.
What I Want to Understand From This Topic
How an application checks whether an XML document follows its expected structure.
Why a well-formed XML file can still fail schema validation.
How XSD defines mandatory elements, data types and element sequences.
How testers can prepare positive and negative XML validation scenarios.
Why schema validation is important when working with ISO 20022 payment messages.
Introduction: One Incorrect XML Value Can Make a Difference
Let's consider a simple payment example.
A bank application receives an XML document containing the following information:
| Field | Sample value |
|---|---|
| Payment Reference | PAY123456 |
| Debtor Name | ABC Technologies |
| Creditor Name | XYZ Solutions |
| Amount | ABC |
| Currency | USD |
At first glance, the payment information seems to be available.
But look at the amount.
Instead of a numeric value, the XML contains ABC.
If the receiving application expects the amount to be a decimal value, this document will not satisfy that requirement.
Now consider another situation.
The amount is correct, but the creditor information is missing.
Would the application accept the message?
The answer depends on the applicable schema and business requirements.
These examples made me interested in understanding how applications check XML documents and how testers can identify such problems.
Before exploring the testing scenarios, let's understand the basic concepts.
1. First, Understand What XML Schema Validation Means
XML Schema Validation is the process of checking whether an XML document follows the rules defined in an XML Schema Definition, commonly known as XSD.
An XSD acts as a reference for the expected structure of an XML document.
It can describe:
Which elements must be present.
Which elements are optional.
The order in which elements should appear.
The expected data type of each element.
How many times an element can occur.
What restrictions apply to element values.
For example, imagine a payment message with three elements:
PaymentReference
Amount
Currency
The XSD can define PaymentReference as a string, Amount as a decimal and Currency as a string.
It can also define whether these elements are required and the order in which they must appear.
For a software tester, these definitions are useful because they provide specific rules that can be converted into test scenarios.
2. What Is the Difference Between Well-Formed XML and Schema-Valid XML?
This is an important concept to understand before moving into practical testing.
Consider the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<Payment>
<PaymentReference>PAY12345</PaymentReference>
<Amount>ABC</Amount>
<Currency>USD</Currency>
</Payment>The tags are correctly opened and closed. The elements are properly nested, and the document has one root element.
So, the XML is well-formed.
But what if the XSD defines Amount as a decimal?
In that case, the value ABC will fail schema validation.
Here is the difference:
Well-formed XML
Checks basic XML syntax.
Examples:
Opening and closing tags must match.
Elements must be properly nested.
Attribute values must be quoted.
The document must have one root element.
Schema-valid XML
Checks whether the document follows the additional rules defined in the XSD.
Examples:
- Mandatory elements must be present.
- Element sequence must be correct.
- Values must follow the expected data types.
- Occurrence restrictions must be respected.
- Defined restrictions and enumerations must be satisfied.
This is something I would want every banking and payment tester to understand.
Checking whether an XML file opens successfully is not the same as checking whether it satisfies its schema.
3. Understanding the XSD Structure
Now let's look at a simple XSD example.
Suppose we want to define a basic Payment XML document containing three elements.
The XSD could look like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Payment">
<xs:complexType>
<xs:sequence>
<xs:element name="PaymentReference"
type="xs:string"/>
<xs:element name="Amount"
type="xs:decimal"/>
<xs:element name="Currency"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>Let's understand what is happening.
| XSD component | Purpose |
|---|---|
| xs:schema | Defines the XML schema |
| xs:element | Declares an XML element |
| xs:complexType | Defines an element that can contain child elements or attributes |
| xs:sequence | Defines the required sequence of child elements |
| xs:string | Defines a string data type |
| xs:decimal | Defines a decimal data type |
One important part is xs:Sequence.
It means the child elements must appear in the order declared in the schema.
For this example, the order is:
Payment Reference
Amount
Currency
If Currency appears before Amount, the XML document will not satisfy this sequence.
There is another detail worth noticing. The elements in this example are required by default because their minimum occurrence is one. An XSD can use attributes such as minOccurs and maxOccurs to change occurrence rules.
Understanding these definitions makes it easier to read and interpret an XSD file.
4. How Would I Approach the XML Validation Process?
Rather than looking at validation as one complicated activity, I find it easier to divide it into smaller steps.
Step 1: Identify the XML document
First, identify which XML file needs to be checked.
In a banking application, this could be a payment initiation message, payment status message or another financial message.
Step 2: Identify the correct XSD
The correct schema must be selected for the relevant message definition and version.
Using an incorrect or outdated schema can produce validation errors that do not represent the actual requirements.
Step 3: Check XML syntax
The parser checks whether the XML document is well-formed.
For example, mismatched tags or incorrect nesting can cause a parsing error.
Step 4: Apply XSD validation
The validation engine checks the document against the schema rules.
This includes element definitions, data types, sequence and occurrence restrictions.
Step 5: Review the validation result
The document either satisfies the schema checks or produces errors.
Step 6: Investigate the problem
The tester reviews the error, identifies the affected element and checks the relevant XSD definition.
The objective is not just to find that validation failed. It is to understand why it failed.
5. What Types of XML Validation Errors Should Testers Look For?
Now comes the part I find particularly useful from a software testing perspective.
A tester should not prepare only one valid XML document and assume that the validation process is working correctly.
We should also consider what happens when the document contains incorrect information.
Here are some common scenarios:
| Validation issue | Example | What should be checked? |
|---|---|---|
| Missing mandatory element | Amount is missing | Mandatory element rule |
| Incorrect data type | Amount contains ABC | Decimal definition |
| Incorrect element sequence | Currency appears before Amount | Sequence definition |
| Invalid enumeration | Unsupported status value | Permitted values |
| Maximum occurrence exceeded | Element appears too many times | Maximum occurrence |
| Unexpected element | Undeclared element is added | Element declaration |
| Invalid date value | Date does not meet the defined format | Date type or pattern |
| Value exceeds length | Reference exceeds the permitted length | Length restriction |
These are useful starting points for preparing negative test cases.
The actual error message may differ depending on the validation tool, but the tester should be able to identify the rule that was violated.
6. How Would I Prepare Positive and Negative Testing Scenarios?
Let's return to the simple Payment XML structure.
The XSD expects:
PaymentReference
Amount
Currency
A tester can prepare different XML documents to check how the validation process behaves.
| Test scenario | Condition | Expected result |
|---|---|---|
| Valid payment XML | All required elements contain suitable values | Validation passes |
| Missing reference | PaymentReference is removed | Validation fails |
| Missing amount | Amount is removed | Validation fails |
| Invalid amount | Amount contains alphabetic characters | Validation fails |
| Incorrect sequence | Currency appears before Amount | Validation fails |
| Missing currency | Currency is removed | Validation fails |
| Unexpected element | An undeclared element is added | Validation fails |
| Valid decimal amount | Amount contains a valid decimal value | Validation passes |
These examples are based on the simplified XSD in this article.
I would start with one valid XML document and then change one condition at a time.
For example:
First, change the amount to an alphabetic value.
Next, restore the amount and remove the currency element.
Then, change the order of the elements.
This approach makes it easier to understand which rule caused the validation failure.
7. Why Are Both Positive and Negative Testing Important?
Imagine a validation process that rejects every XML document.
Would that be useful?
Of course not.
Now imagine a system that accepts every document, even when mandatory elements are missing or values have incorrect data types.
That would also be a problem.
Positive testing checks whether valid XML documents are accepted.
Negative testing checks whether invalid XML documents are rejected correctly.
Both are necessary to understand whether the validation process is working as expected.
There is another area worth considering: error handling.
For example, compare these two messages:
"Validation Failed."
"Amount contains an invalid decimal value."
Which one would help a tester investigate the problem faster?
The second message gives a clearer indication of what needs attention.
Meaningful error reporting is an important part of testing XML-based applications.
8. Why Is XML Schema Validation Important in ISO 20022 Payments?
This is the area I particularly wanted to connect with my payment-domain learning.
ISO 20022 uses structured messages to exchange financial information between organizations and applications.
Some examples include:
- Customer Credit Transfer messages.
- Financial Institution Credit Transfer messages.
- Payment Status Report messages.
- Payment Return messages.
- Bank-to-Customer Account Report messages.
These messages follow defined structures, and their XSD schemas describe the elements and restrictions that apply to the relevant message definition.
For example, a payment message can contain debtor details, creditor details, transaction information and payment amounts.
A missing mandatory element or an incorrect data type can cause the XML document to fail schema validation.
However, one important point should not be overlooked.
Passing XSD validation does not automatically mean that a payment is ready for processing.
The message may still fail additional business checks.
For example:
- An account may not satisfy the applicable business requirements.
- A transaction may violate a business rule.
- A payment may contain an unsupported combination of values.
- Additional scheme or operational checks may be required.
This is why I would separate XML syntax validation, XSD validation, business-rule validation and payment-processing checks when thinking about testing coverage.
Each serves a different purpose.
🛍️✨ From the author · ByteStore1,000 XML Intermediary Payment Questions & Answers β ISO 20022 Intermediary PaymentsβΉ1,900View offer →9. Which Tools Can Help With XML and XSD Validation?

When learning XML validation, it is useful to explore tools that allow you to open XML and XSD files and inspect validation results.
Here are some options worth considering.
Notepad++
Useful for viewing XML and XSD files, formatting content and understanding document structure. Validation may require an appropriate plugin.
Visual Studio Code
Can be used to edit XML and XSD files. XML extensions can provide formatting, schema association and validation features.
Oxygen XML Editor
A dedicated XML environment that supports XML editing, schema validation and error analysis.
Java XML Validation APIs
Java provides APIs that developers can use to validate XML documents against XSD schemas.
Python with lxml
The Python lxml library can be used for XML parsing and XSD validation in practical learning exercises.
The tool you choose depends on your technical environment and the type of validation exercise you want to perform.
For someone starting with XML and XSD, I would begin with a simple XML document and its corresponding schema before moving to larger financial messages.
10. What Should a Banking and Payment Tester Check?
When exploring XML schema validation, I would organise the testing activities into a few areas.
XML Structure
Is the document well-formed?
Does it contain the expected root element?
Are the elements properly nested?
XSD Rules
Are mandatory elements present?
Are elements in the correct sequence?
Are minimum and maximum occurrences respected?
Data Values
Are the expected data types followed?
Are numeric and date values valid?
Are restrictions and enumerations satisfied?
Schema Configuration
Is the correct XSD version being used?
Are namespaces declared correctly?
Are schema imports and includes resolved?
Error Handling
Are invalid XML documents rejected?
Can the validation error be understood?
Can the affected element be identified?
This gives testers a starting point for building XML validation coverage.
For an actual payment project, these checks should be extended using the applicable message specification and business requirements.
11. What Does This Teach Us About Software Testing?
For me, the interesting part of learning XML schema validation is understanding the connection between technical rules and testing activities.
Consider two situations.
One tester checks whether an amount field accepts a decimal value.
Another tester asks:
Can the amount be zero?
Are negative values permitted?
How many decimal places are allowed?
What happens when the amount exceeds the defined restriction?
Are there additional payment-specific rules?
These questions help identify the difference between checking a technical data type and understanding the wider business requirement.
Both are useful, but they address different levels of validation.
Here are a few lessons I would keep in mind:
Understand the schema before preparing test cases.
The XSD provides the structure and restrictions that need to be tested.
Check both valid and invalid XML documents.
Positive and negative testing help verify the validation behaviour.
Do not confuse schema validation with business validation.
An XML document can pass XSD validation and still fail a business rule.
Pay attention to error messages.
A useful validation result should help identify the problem.
Understand the payment message being tested.
In ISO 20022, knowing the purpose and structure of the message makes testing more meaningful.
12. Who Can Benefit From Learning XML Schema Validation?
This topic can be useful for different professionals working with applications that exchange structured data.
Manual Testers
It helps them understand XML structure, validation requirements and negative test scenarios.
Automation Testers
It provides a foundation for automating XML parsing and schema validation checks.
Banking and Payment Testers
It helps them understand how payment messages are checked against defined XML structures.
Business Analysts
It helps them understand mandatory elements, data requirements and message structures.
Freshers and Beginners
It provides a starting point for learning XML, XSD and structured data validation.
You do not need to understand every ISO 20022 message before beginning. Start with a small XML example and gradually explore more complex structures.
Conclusion: Understand the XML, Read the XSD and Think Like a Tester
When I started exploring XML Schema Validation, I wanted to understand how banking and payment applications determine whether an XML document follows the expected rules.
The examples in this article helped me connect three important concepts:
XML defines the structured information.
XSD describes the rules that the XML document must follow.
Software testing checks whether the document and the application behave as expected.
There is still more for me to explore, particularly around XML namespaces, cardinality, restrictions, schema imports and actual ISO 20022 message structures.
My suggested starting point for anyone learning this topic is simple.
Take a small XML file.
Find or create its corresponding XSD.
Validate the document.
Change one value or remove one element.
Then investigate why the validation result changes.
This is a practical way to build your understanding before moving towards more complex banking and payment messages.
Don't just learn what an XSD is. Understand what it checks and how you would test it.
Let's Start a Conversation
I would like to hear your perspective.
If you were testing an ISO 20022 XML payment message, what would you check first?
Would you start with mandatory elements, data types, element sequence or namespaces?
Share your thoughts in the comments. It would be interesting to learn how other payment and software testers approach XML validation.
If you are interested in Software Testing, Banking, Payments, ISO 20022 or Payment Technology, let's connect and learn together.
About the Author
Abhilash Nair
Payment Domain Specialist | Software Testing | Banking Technology
CareerByteCode β Learn. Practice. Master Payment Technology.
Explore more payment learning resources:
✅ Quick check
3 questions to see what stuck.
🛍️ Abhilash Nair's shelf
Courses, cohorts and more from the authorGet Abhilash Nair's next blog by email
One email a week when they publish. Add the weekly Best of ByteBlog too. No spam, unsubscribe with one click.
We email you once to confirm. By subscribing you agree to the privacy policy.
More from Abhilash Nair

Payment File Validation Tool: A Practical Project for Testers
Learn how to plan a payment file validation tool, identify key payment data checks, and design practical software testing scenarios.
#banking-technology
Technology Leadership: The Leader I Aspire to Be
Payment Domain Specialist | Software Testing | Banking Technology

💬 Comments (0)
Top · NewestSign in to comment