1

I am developing a program where I want to create XSD file alongside the XML file.

Like if XML file updates then XSD file will also be updated instantly.I have written code using DOM approach that creates an XML file and can be updated upon users action.Now I also want to create an XSD file that would be used to validate the XML file at any time and also to define data structure of the XML file.

Is there any way to create XSD file alongside with XML file so that XSD file updates whenever XML file updated using DOM approach??

1 Answer 1

1

You can try xsd-gen which allows to generate a XSD file from a XML file:

XsdGen gen = new XsdGen();
gen.parse(new File("in.xml"));
File out = new File("out.xsd");
gen.write(new FileOutputStream(out));

The the current latest version is 0.2.1 and is available from here.

You will also need to add to your classpath/project all its compile dependencies which are:

  1. com.google.code.cli-parser:cli
  2. org.wiztools.commons:wiztools-commons-lib
  3. xom:xom
Sign up to request clarification or add additional context in comments.

5 Comments

I haven't find XsdGen class.Is it from an external library?
I couldn't import the package after adding the folder as a source folder. It showing package declaration error!!How can I use it?
as a source folder? why as source folder? download it from here mvnrepository.com/artifact/org.wiztools/xsd-gen/0.2.1 and add it to your classpath
While creating XsdGen object It's giving me a java.lang.NoClassDefFoundError:. how can I fix it?
Check the compile dependencies listed here mvnrepository.com/artifact/org.wiztools/xsd-gen/0.2.1 and for each of them download the corresponding jar and add it to your classpath/project

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.