views:

61

answers:

2

hi,

in my company they have came up with their own xml that is being used as a schema for data, now i have to validate a xml according to that schema. is there any easy way to do it or i have to write from scratch?

i am working with java6...

thanks

+1  A: 

Check out Package javax.xml.validation , as of Java 5 the API supports validation for custom schema.

The SchemaFactory object has a method newSchema that will take a file and create a schema from it that can be validated against.

Edit: If you need to convert your XML file to a schema look at this question: http://stackoverflow.com/questions/74879/any-tools-to-generate-an-xsd-schema-from-an-xml-instance-document

Mark Robinson
Downvoted b/c you don't have a schema to work with ? Are you calling your xml document a schema ?
Mark Robinson
+1  A: 

One possibility is to create an XSLT transform that converts the homegrown schema document into a standard such as XML Schema or Relax NG.

kdgregory
Would whoever downvoted care to comment and explain why my answer is incorrect? Or is it simply not what you wanted to hear?
kdgregory