1

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

special0ne
  • 6,063
  • 17
  • 67
  • 107
  • You'll have to write it from scratch. If you post samples of the "schema" and instance documents, we might be able to point you in the right direction. However, unless your coworkers have some experience in building grammars, chances are good that the "schema" won't be a rigorous definition. – kdgregory Jan 14 '10 at 12:48

2 Answers2

1

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: Any tools to generate an XSD schema from an XML instance document?

Community
  • 1
  • 1
Mark
  • 16,772
  • 9
  • 42
  • 55
  • Downvoted b/c you don't have a schema to work with ? Are you calling your xml document a schema ? – Mark Jan 14 '10 at 13:11
1

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
  • 38,754
  • 10
  • 77
  • 102
  • Would whoever downvoted care to comment and explain why my answer is incorrect? Or is it simply not what you wanted to hear? – kdgregory Jan 14 '10 at 13:07