Talend Tip: Validating XML file with XML Schema (XSD)

All of us know that generating XML data in the integration process is easy, however, generating an XML file that is compliant with the standard of a target application is hard as the data from the source application may be different from the target application. The best practice to prevent sending invalid XML data to the target application is to validate it against the XML schema (XSD).


In Talend, you can use the tXSDValidator component to do this for you. As you can see in Figure 1 below, you just need to specify the XML schema to use an XML data file to be validated.

Figure 1: tXSDValidator configuration


Here is the sample scenario. I have created an XML data that contains “Australia” as the country,


Allan Road Sydney 5415 Australia

However, the XML schema only allows a fixed set of values such as “AU”, “NZ” and etc.

                NEW ZEALAND


When I run the job, I will see the following error:

Figure 2: Invalid XML


Once I fixed the error at line 15 and 26 as shown in the error message, I should get a successful validation.


Allan Road Sydney 5415 AU

Figure 3: Valid XML