I am using xslt to convert my html to docx file format(which is in open office xml format). When i open some generated docx file in word, its showing error(may be a mistake in xml nodes).Is it possible to find 开发者_开发问答whether the created document will open or show errors while opening or Is it possible to recover the document programmatically(what word do if the document contains error)? or any word api to use in our code to recover
Please help me.. Thanks in advance...
Try checking the relationships xml file within word/_rels and contrast it versus a working docx. My docx files get corrupted when I forget to add the corresponding entries in there.
Update: Also check all your image file extensions are defined in the [Content_Types].xml file.
Is it possible to find whether the created document will open or show errors while opening
In theory, you should be able to use a validating XML parser to validate your created document against the XML schemas for OOXML. In practice:
- You might need to do to searching to locate machine readable versions of the relevant schema.
- It is not inconceivable that the problems are due to things that would not be picked up by schema validation.
Is it possible to recover the document programmatically(what word do if the document contains error)?
In general no. If the document is sufficiently different from what MS Office expects, it won't be able to "make head nor tail of it". (It ain't magical ...)
or any word api to use in our code to recover
Again, no. If the document is sufficiently different from the schema, a schema-conforming reader / writer API won't be able to cope with it.
The real solution is to figure out what the errors in your conversion software are and rectify them. Apart from validating against the schema, there are unlikely to be any real short-cuts.
Probably your file may gone have corrupted. For this you need to recover it using some third part word recovery tool.
精彩评论