We are going to validate XML using XSD schema in Java. We will create XML Schema using XSD and then use same schema to create the XML file. Then we will write our code to validate this XML against same schema. XSD Schema creation Below is our schema where we are defining the Schema for XML elements. In this schema we creating two elements, one for request and another for response. We are publishing this schema using targetNamespace which we will use during XML creation. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://services.ttj.com/hello-service" targetNamespace="http://services.ttj.com/hello-service" elementFormDefault="qualified"> <xs:element name="sayHelloRequest"> <xs:complexType> <xs:sequence> <xs:element name="userName" type="xs:string"/> </xs:sequence> </xs:c...
Blogs about Java, J2ee, Multithreading, Data structure, Algorithm, Spring framework, Spring boot, Web services and open source technologies