1

I have a document that will constantly be updated and consists of text and tables. The tables have two rows, one which ranges of numbers and the second with a single number.

I would like to check if the number in row 2 is within the range given in row 1. I would like to do this using XMLs and XSDs. My original thought was to create an XSD from the word doc, then an XML from the word doc (save the file as a .xml) and then run both files through a vaidator. However, I am having trouble writing the XSD. A lot of sources online say to generate an XSD from and XML and use that XSD to validate the XML. But the problem is if I do this, I'm not seeing any ranges specified in the XSD. It just looks like doc formatting specifications. Does anyone know if there any tools to do this task or is this something where I need to generate the XSD manually. My ultimate goal is to automate the process such that given a doc, I have an XSD and can generate an XML, then I can just change values in the XML and see if it is in a valid range according to the XSD(which should check ranges). I am really stuck on how I can automate this process (or even if there is a way to automate it)

EDIT: This is actually how one can do restrictions with ranges in schema - http://www.w3schools.com/xml/schema_facets.asp

user4500293
  • 621
  • 1
  • 7
  • 18

1 Answers1

0

Microsoft Word documents since Word 2007 are saved in a DOCX format that follows the Office Open XML (OOXML) standard. Start by reading this Office Open XML Overview. Knowing this, you'll then be able to construct some reasonable searches to find OOXML tutorials and code samples. Understand that this is not an easy first project in XML.

I would like to check if the number in row 2 is within the range given in row 1. I would like to do this using XMLs and XSDs.

XSDs are not appropriate here. XPath would be better suited for retrieving and checking values in this manner.

My ultimate goal is to automate the process such that given a doc, I have an XSD and can generate an XML, then I can just change values in the XML and see if it is in a valid range according to the XSD(which should check ranges).

Again, although there are XSDs for OOXML (the XML behind DOCX), they support extreme amounts of baggage unnecessary to your project. Look instead into streamlined access to the data you seek via XPath calls from the language of your choice. You'll have to understand the data model, so be sure to read the OOXML references mentioned above first.

kjhughes
  • 106,133
  • 27
  • 181
  • 240