How Can I create XSD from XML File using java & Eclipse?

11,306

Solution 1

You can use Intellij Ultimate edition to create and XSD from XML.it is an ALL in one ide which acan be used for several purposes.

create XML file go to tools> XML tools> generate XSD file. 😀

Solution 2

There are tools to create an XSD from an XML instance (or a set of instances) but they will never create an XSD that is suitable for production use - it will always need manual tweaking. Therefore, this is not something you would normally do from a Java application.

The reason is that the tools have to make guesses. Just because all the prices in your sample data are more than $10.00, and all the book titles consist entirely of ASCII letters and spaces, doesn't mean that this will also apply to the prices and titles in the next document you want to process. Equally, if every book element in your sample has exactly one author, that doesn't stop the next sample containing a book with no author or several authors.

Share:
11,306
Akshay Kamble
Author by

Akshay Kamble

Updated on June 26, 2022

Comments

  • Akshay Kamble
    Akshay Kamble almost 2 years

    I want to create XSD from xml document using java code.I tried with different solution using XsdGen & Xbean jar,but it won't work.You can referred this also:http://www.codesuggestions.com/java/how-to-create-xsd-from-xml-using-java-application/. My task is able to generate XSD from XML and If I changed that xml then another xsd also get append or merge with previous one xsd .Let say, I have xml1,xml2...xml5 document file, for all these xml documents generate only one XSD.

    Condition: Suppose, I have xml1.xml file i.e.

       <?xml version="1.0" ?>
       <Student>
            <RollNo>123</RollNo>
            <Name>xyz</Name>
       </student>
    

    For this xml, It will be generate Student.xsd and If I change previous xml i.e.xml1.xml then It should verified that Student.xsd available or not If available then make changes in that XSD otherwise append new XSD to old XSD.

    Thanks.