This utility allows you to export the attribute definitions from the current module to an HTML file. The export is simple and intended to be used as a reference for inexperienced DOORS users.
The output is in table format and includes Attribute Name, Description, Base Type, Permitted Values and Default Value.
There are separate tables for module and object attributes.
// Export Attributes /* Tony Goodman Initial Version */ pragma runLim, 0 int aName = 0 int aDescription = 1 //int aTypeName = 2 int aBaseType = 2 int allowedValues = 3 int defVal = 4 int NUM_COLUMNS = 5 string COLUMN_HEADERS[] = { "Name", "Description", "Base Type", "Permitted Values", "Default Value" } int COLUMN_WIDTHS[] = { 20, 30, 15, 15, 15 } string COLUMN_VALUES[] = { "", "", "", "", "" } DB dbMain = null DBE dbeFileName = null Module m = null string outputFile = "" Buffer tempBuf = create Buffer htmlBuffer = create Buffer enumerations = create /******************* emitHeader ***********************/ void emitHeader() { htmlBuffer += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" htmlBuffer += "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" htmlBuffer += "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" htmlBuffer += "<head>\n" htmlBuffer += "<style>\n" htmlBuffer += ".myCell {\n" htmlBuffer += "margin: 0px;\n" htmlBuffer += "padding: 5px;\n" htmlBuffer += "vertical-align: top;\n" htmlBuffer += "font: 11px Arial, sans-serif;\n" htmlBuffer += "border: 1px solid #CCCCCC;\n" htmlBuffer += "}\n" htmlBuffer += ".myTable {\n" htmlBuffer += "margin: 0px;\n" htmlBuffer += "padding: 0px;\n" htmlBuffer += "vertical-align: top;\n" htmlBuffer += "}\n" htmlBuffer += "</style>\n" htmlBuffer += "</head>\n" htmlBuffer += "<body>\n" } /****************** emitFooter ***********************/ void emitFooter() { htmlBuffer += "</body>\n" htmlBuffer += "</html>\n" htmlBuffer += "\n" } /************************** getValues ***********************/ void getValues(AttrDef ad) { AttrType at = null AttrBaseType abt = null string isMulti = "" int enumSize = 0 int i = 0 for (i = 0; i < NUM_COLUMNS; i++) { COLUMN_VALUES[i] = "" } setempty(enumerations) at = ad.type abt = at.type if (abt == attrEnumeration) { enumSize = at.size for (i = 0; i < enumSize; i++) { enumerations += at.strings[i] "\n" } if (ad.multi) { isMulti = "\n(Multi-valued)" } COLUMN_VALUES[allowedValues] = stringOf(enumerations) isMulti } COLUMN_VALUES[aName] = ad.name COLUMN_VALUES[aDescription] = ad.description //COLUMN_VALUES[aTypeName] = ad.typeName COLUMN_VALUES[aBaseType] = abt "" if (ad.defval) { COLUMN_VALUES[defVal] = plainText(ad.defval) } if (ad.dxl) { COLUMN_VALUES[allowedValues] = "(Automatically populated)" } } /*************************** exportAttrs **************************/ void exportAttrs(string tableTitle, bool modAttrs, bool objAttrs) { AttrDef ad = null int i = 0 bool isHidden = false bool isSystem = false htmlBuffer += "<table class=\"myTable\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n" htmlBuffer += "<tr>\n" htmlBuffer += "<td colspan=\"6\" class=\"myCell\"><b>" tableTitle "</b></td>\n" htmlBuffer += "</tr>\n" htmlBuffer += "</table>\n" htmlBuffer += "<table class=\"myTable\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n" htmlBuffer += "<tr>\n" for (i = 0; i < NUM_COLUMNS; i++) { htmlBuffer += "<th width=\"" COLUMN_WIDTHS[i] "%\" class=\"myCell\"><b>" COLUMN_HEADERS[i] "</b></th>\n" } htmlBuffer += "</tr>\n" for ad in m do { isSystem = ad.system if (ad.system) continue isHidden = ad.hidden if (ad.hidden) continue if (ad.module && !modAttrs) continue if (ad.object && !objAttrs) continue htmlBuffer += "<tr>\n" getValues(ad) for (i = 0; i < NUM_COLUMNS; i++) { if (COLUMN_VALUES[i] == "") { htmlBuffer += "<td class=\"myCell\"><br></td>\n" } else { htmlBuffer += "<td class=\"myCell\">" setempty(tempBuf) tempBuf += COLUMN_VALUES[i] safeHTMLBuffer(tempBuf, true, true) htmlBuffer += tempBuf htmlBuffer += " </td>\n" } } htmlBuffer += "</tr>\n" } htmlBuffer += "</table>\n" } /***************************** doExport *****************************/ void doExport(DB db) { Stream st = null outputFile = get(dbeFileName) st = write(outputFile) if (null st) { infoBox("failed to open file for writing: " outputFile) return } emitHeader() //exportAttrs("Object and Module Attributes", true, true) exportAttrs("Module Attributes", true, false) exportAttrs("Object Attributes", false, true) emitFooter() st << htmlBuffer //"Exported from DOORS module " fullName(m) " on " stringOf(dateOf(intOf(today)), "dd MMMM yyyy") "\n" close(st) infoBox("Export complete!") release(dbMain) } /**************************** buildDialog ******************************/ void buildDialog() { dbMain = create(m, "Export Attributes to HTML", styleCentered) label(dbMain, "This utility exports attribute details to an HTML file.\n\n") dbeFileName = fileName(dbMain, "Export to:", "U:\\" name(m) " Attributes.html", "*.html", "HTML Files", false) apply(dbMain, "Export", doExport) realize(dbMain) block(dbMain) destroy(dbMain) dbMain = null } /********************************** exportAttributes *****************************/ void exportAttributes() { m = current Module buildDialog() } exportAttributes()