10103

XML/XSD validation for a Word doc

Question:

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 - <a href="http://www.w3schools.com/xml/schema_facets.asp" rel="nofollow">http://www.w3schools.com/xml/schema_facets.asp</a>

Answer1:

<sup><sub><strong>Preface</strong>: Ken White is right when he <a href="https://stackoverflow.com/questions/37801066/xml-xsd-validation-for-a-word-doc#comment63067852_37801066" rel="nofollow">comments</a> that you should improve your existing question rather than re-ask it without substantial improvement. I'll place this answer here since this version of your question is slightly better than the other; please delete the other.</sub></sup>

Microsoft Word documents since Word 2007 are saved in a DOCX format that follows the <a href="http://www.ecma-international.org/publications/standards/Ecma-376.htm" rel="nofollow">Office Open XML</a> (OOXML) standard. Start by reading this <a href="http://www.ecma-international.org/news/TC45_current_work/OpenXML%20White%20Paper.pdf" rel="nofollow">Office Open XML Overview</a>. 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.

<blockquote>

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.

</blockquote>

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

<blockquote>

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).

</blockquote>

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.

Recommend

  • PDO “exception safety” and writing it to a log file PHP
  • GoogleAuthUtil cannot be resolved
  • What is the correct way to escape text in JSON responses?
  • Renderscript broken with AndroidX?
  • How can I split a CDockablePane?
  • How do I use the private key from a PFX certificate stored in Azure Key Vault in .NET Core 2?
  • Angular 4 Animation won't trigger on route change
  • Unity3D display Google Admob slow
  • Sequelize belongsToMany additional attributes in join table
  • Tooltip on Hover of select box options generated by ng-options in Angularjs
  • Using MS Dynamics NAV with PHP [closed]
  • Does OAuth “state” mitigate any genuinely dangerous attacks?
  • Images tile on Google map in android
  • How to access a bundled ES6 class in inline
  • Create intance of any C# class by generic way
  • swift UIView animateWithDuration with repeat and autoreverse
  • Can the use of C++11's 'auto' deteriorate performance or even break the code?
  • Ruby on Rails - Settting up Reviews functionality
  • Google Chrome compositor-driven animation affected by jam in main thread
  • How to resume hash slots of a particular node in redis cluster in case of hard failure?
  • Highcharts Drawing a line with chart.renderer.path
  • what is “Other” category in CosmosDB monitoring graph?
  • how can i close the resultSet, prepareStatement, conn in several methods below to avoid rs close and
  • iOS: Address Book
  • Create One-To-One relationship between table and view in EF4?
  • remove date from DateTimePicker for Compact Framework
  • Identifying dates in strings using NLTK
  • Move elements from a listbox to another
  • Thick underline when hover AND when active
  • How to delete first 7 characters of folder name by using batch script?
  • Force fading edge on TextView
  • Align microsoft access queries
  • How to create OLE Automation to be used with ClearExplorer
  • Facebook Error (#200) The user hasn't authorized the application to perform this action (PHP)
  • How to load dynamic images in custom ListView
  • What is the difference between dynamically creating a script tag and statically embed a script tag?
  • How convert html to BBcode in C#
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner
  • How to mutate multiple variables without repeating codes?