views:

65

answers:

1

I would like to validate a given Word 2007 XML file against the Schema defined in wml.xsd. How could it be done in Java? Loading the Schema with the following line is not a problem. But it seems that I have to tweak the validation process becaus I get error messages even on valid input files (I could open and view the input file in Word 2007 without warnings)

Schema schema = schemaFactory.newSchema(source); // <-- complains on valid input files
Validator validator = schema.newValidator();
+1  A: 

There is a chance, that the word file is usable in word as well as invalid according to the schema. Could be, that the word file uses a different version of the schema, could be that MS word relaxes a bit on invalid files.

To check, I'd load file and schema into an eclipse project - eclipse need to be equipped with the web standard tools plugin - and open the word xml file with the xml editor. The editor will show validation errors (you may have to execute the validate action manually)

Andreas_D