README for Updating MDL Mapping Tables

An automated process has been developed to simplify maintenance of tables that
map MDL elements to IRIG 106-17 Chapters, component specifications, etc. To
accomplish this, a copy of the MDL schema “tagged” with keywords and interfaces
is used.

Included in the zip file with this README is the tagged schema and a Python
script. The tagged schema may also be referred to as the database in this
README. The Python script is used update the database and generate CSV files
that can be formatted with Excel. This script requires Python 3.x and lxml.

--- Updating the Database ---

After modifying the MDL schema, perform the following steps to update the
database. Note: <OLD> represents the previous MDL schema version and <NEW>
represents the modified MDL schema version.

1. create <OLD> CSV file from database
    python spreadsheets.py export MDL_v<OLD>-tags.xsd mdl2if_v<OLD>.csv

2. create database using <NEW> schema and <OLD> tags (saves output to MDL_v<NEW>-tags.xsd)
    python spreadsheets.py process MDL_v<NEW>.xsd mdl2if_v<OLD>.csv > MDL_v<NEW>-tags.xsd

3. create <NEW> CSV file from database
    python spreadsheets.py export MDL_v<NEW>-tags.xsd mdl2if_v<NEW>.csv

4. diff mdl2if_v<OLD>.csv and mdl2if_v<NEW>.csv
    - verify tags copied from <OLD> CSV are still correct
    - fill in empty tags in <NEW> CSV file

5. update database using <NEW> schema and <OLD> tags (saves output to MDL_v<NEW>-tags.xsd)
	python spreadsheets.py process MDL_v<NEW>.xsd mdl2if_v<NEW>.csv > MDL_v<NEW>-tags.xsd

--- Releasing the MDL Schema ---

The MDL schema file should not be released with tags (the database is not the
official schema). Use the following steps to create a releasable schema file
from the database.

1. create blank CSV file from database
	python spreadsheets.py create interfaces MDL_v<NEW>-tags.xsd blank.csv
2. create releasable schema file (saves output to MDL_v<NEW>.xsd)
	python spreadsheets.py process MDL_v<NEW>-tags.xsd blank.csv > MDL_v<NEW>.xsd

--- Updating the MDL Elements to IRIG 106-17 Chapters Spreadsheet ---

After updating the database, perform the following steps to update the MDL
Elements to IRIG 106-17 Chapter Mapping spreadsheet, which is referenced in
Appendix 23B of IRIG 106-17 Chapter 23.

1. Create the chapter mapping CSV file
    python spreadsheets.py build_ch all MDL_v<VER>-tags.xsd MDL_v<VER>_chapter_mapping.csv
2. Open chapter_mapping.csv in Excel to add formatting, filters, etc…
3. Save chapter_mapping.csv as Excel spreadsheet

--- Updating MDL Elements to Components Spreadsheet ---

After updating the database, perform the following steps to update the MDL
Elements to component mapping spreadsheet.

If necessary, also update interface component mapping spreadsheet.

1. Create the individual component CSV file
	python spreadsheets.py build <COMPONENT> schema/MDL_v<NEW>.xsd spreadsheet.csv
2. Copy data from spreadsheet.csv into the component mapping spreadsheet (specific tab for that component)
3. Repeat for all components
