How to validate XML vs XSD in Java
In this tutorial, we will use XML Validation API to validate XML vs XSD in Java. Specifically, we will use the javax.xml.validation.Validator class to validate XML vs XSD in this program. Now, we see the sample XSD and XML files, below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="https://www.javabycode.com/Fruit" xmlns:fruitns="https://www.javabycode.com/Fruit" elementFormDefault="qualified"> <element name="fruit" type="fruitns:fruit"></element> <complexType name="fruit"> <sequence> <element name="id" type="int"></element> <element name="name" type="string"></element> <element name="produceby" type="string"></element> </sequence> </complexType> </schema> |
And you should create xml file from xsd file by using eclipse. See … Read moreHow to validate XML vs XSD in Java