Automate HTML export of a module

Hi all,

This is my first post in this forum.  Nice to meet everyone.

I have a question related to automatize HTML export of a module.
The use case at the end should be that from a .bat file i can lunch the HTML export of a specified module and save it to a particular folder.

I've seen from other post:
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014305335#repliesPg=0
and from an official technote:
http://www-01.ibm.com/support/docview.wss?uid=swg21567793

that is possible to automate word export of a module from batch mode execution.

I tried to extend this method from HTML export, that is lunched from a module by using meu file-> export-> html...
I've located the dxl lib related to HTML export at the directory:
C:\\Programmi\\IBM\\Rational\\DOORS\\9.6\\lib\\dxl\\standard\\export\\html.dxl
but it is encripted.

I've tried to modify the export_batch.dxl in this way:

 // override some default message box functions, so they will only print the data but  
// not pause execution. Write to a log file here!  

  

bool confirm (string s) { print "Confirmed: " s "\n"; return true } 

void ack (string s) {print "Acknowledge: " s "\n" } 

// void acknowledge (string s) {print "Acknowledge: " s "\n"  } 

void infobox (string s) {print "Info: " s "\n" } 

void info (string s) {print "Info: " s "\n" } 

  

DB theDiag = null 

  

// Now override block and show, to only do realize 

void show  (DB x) { realize x; theDiag = x } 

void block (DB x) { realize x; theDiag = x } 

  

if (null current Module) { 

 print "You need to have a current Module set for the export." 

 halt 

} 

  

// we need braces, since -D will be executed at top level and we will get name 

// clashes for variable defined in word.dxl and the other includes of it. 

{ 

 // now include the word.dxl -> this will pop up the dialog, but not halt execution 

 // due to the overrides above 

 // #include <standard/export/office/word.dxl> 
 //#include <standard/export/html.dxl> 
 #include "C:\\Programmi\\IBM\\Rational\\DOORS\\9.6\\lib\\dxl\\standard\\export\\html.dxl" 

 // here we can change the dialog options. See itfui2.inc and word.dxl for all  

 // the options 

 //set(exportHeadingsToggle, false)   // turn off export of headings 

 //set(exportLayoutChoice, 1) 



 // now manually launch the export button callback 

 //doExport theDiag 

 

 // get rid of the dialog 

 //if (!null theDiag) destroy theDiag 

  

 // close DOORS 

 //exit_ 

}

I've commented some part and included the HTMLexport library.
my issues are:
-don't know the lunch command from HTML export, by including the lib the HTML export promp pops up by i can't automative the "lunch export" button pressing.
in word export the command is "doWord theDiag" but it is not working with HTML.
-don't know how to modify the export parameters, for example table/book layout, export directory, link presence, etc..
-don't know  how parameters of HTML export are called, because the html.dxl lib is encripted.

Can anyone help me?
thank you


SamueleMazzoleni - Wed Feb 15 08:37:26 EST 2017

Re: Automate HTML export of a module
GothSloth - Wed Feb 15 13:35:47 EST 2017

Bummer...in 9.5.1.2 its not encrypted. Anyways the file lib\\dxl\\standard\\export\\html.dxl contains the dialog box for the export. The code that actually does the export is in the file lib/dxl/util/libthml.dxl. The first function in this file called is do_export_file(DB db_local). Looks like it is reading from the dialog box export options, doing some house keeping for open modules, and then calling dumpSingleMod in the same file.  Hopefully this file is also not encrypted for you. You will probably need to make a copy of this file and take out the dialog/box and progress box stuff to get it running from batch mode.

Re: Automate HTML export of a module
SamueleMazzoleni - Tue Feb 21 03:19:54 EST 2017

Thank you very much for the tip, it did the job.

Using 9.5 html.dxl and libhtml.dxl i am able to lunch the export with command  "do_export_file theDiag".

theDiag is a dialog box that is built before in the dxl and can configure all export switch.

I'm not able to modify the path of the export, so the default one is used.

As default Doors uses this rules:

last exported directory (folder) + doors module name, for example:

C:\Users\samuelma\Desktop\prova\_ProjectTest_Samuele_Export_html_modulo_con_link.htm

and C:\Users\samuelma\Desktop\prova\ was the previous export directory.

is there a way to change the export directory path from dxl?

 

Here's is the code i'm using for the export:

// override some default message box functions, so they will only print the data but  
// not pause execution. Write to a log file here!  

bool confirm (string s) { print "Confirmed: " s "\n"; return true } 
void ack (string s) {print "Acknowledge: " s "\n" } 

// void acknowledge (string s) {print "Acknowledge: " s "\n"  } 
void infobox (string s) {print "Info: " s "\n" } 
void info (string s) {print "Info: " s "\n" } 

DB theDiag = null 

// Now override block and show, to only do realize 
void show  (DB x) { realize x; theDiag = x } 
void block (DB x) { realize x; theDiag = x } 

if (null current Module) { 
 print "You need to have a current Module set for the export." 
 halt 
} 

// we need braces, since -D will be executed at top level and we will get name 
// clashes for variable defined in word.dxl and the other includes of it. 
{ 
// now include the word.dxl -> this will pop up the dialog, but not halt execution 
// due to the overrides above 
#include <standard/export/html.dxl> 

// here we can change the dialog options. See itfui2.inc, libhtml.dxl riga 41 and html.dxl for HTML export options.  
//***********html export options
set(linksToggle, true)   // turn ON/OFF link in export
set(emptyAttributeToggle, true) // turn ON/OFF empy attribute export


// now manually launch the export button callback 
do_export_file theDiag //html export version
 
// get rid of the dialog 
if (!null theDiag) destroy theDiag 

// close DOORS 
exit_ 
}

Thanks

 

Re: Automate HTML export of a module
O.Wilkop - Tue Feb 21 07:22:16 EST 2017

SamueleMazzoleni - Tue Feb 21 03:19:54 EST 2017

Thank you very much for the tip, it did the job.

Using 9.5 html.dxl and libhtml.dxl i am able to lunch the export with command  "do_export_file theDiag".

theDiag is a dialog box that is built before in the dxl and can configure all export switch.

I'm not able to modify the path of the export, so the default one is used.

As default Doors uses this rules:

last exported directory (folder) + doors module name, for example:

C:\Users\samuelma\Desktop\prova\_ProjectTest_Samuele_Export_html_modulo_con_link.htm

and C:\Users\samuelma\Desktop\prova\ was the previous export directory.

is there a way to change the export directory path from dxl?

 

Here's is the code i'm using for the export:

// override some default message box functions, so they will only print the data but  
// not pause execution. Write to a log file here!  

bool confirm (string s) { print "Confirmed: " s "\n"; return true } 
void ack (string s) {print "Acknowledge: " s "\n" } 

// void acknowledge (string s) {print "Acknowledge: " s "\n"  } 
void infobox (string s) {print "Info: " s "\n" } 
void info (string s) {print "Info: " s "\n" } 

DB theDiag = null 

// Now override block and show, to only do realize 
void show  (DB x) { realize x; theDiag = x } 
void block (DB x) { realize x; theDiag = x } 

if (null current Module) { 
 print "You need to have a current Module set for the export." 
 halt 
} 

// we need braces, since -D will be executed at top level and we will get name 
// clashes for variable defined in word.dxl and the other includes of it. 
{ 
// now include the word.dxl -> this will pop up the dialog, but not halt execution 
// due to the overrides above 
#include <standard/export/html.dxl> 

// here we can change the dialog options. See itfui2.inc, libhtml.dxl riga 41 and html.dxl for HTML export options.  
//***********html export options
set(linksToggle, true)   // turn ON/OFF link in export
set(emptyAttributeToggle, true) // turn ON/OFF empy attribute export


// now manually launch the export button callback 
do_export_file theDiag //html export version
 
// get rid of the dialog 
if (!null theDiag) destroy theDiag 

// close DOORS 
exit_ 
}

Thanks

 

file_name = ((getenv (NLS_("EXPORTDIRECTORY"))) FileSep_ goodFileName(fullName expMod) ((platform == (NLS_((NLS_("WIN32"))))) ? (NLS_(".htm")) : (NLS_(".html"))))

is how the code figures out what path to put, this means with a line of code like:

 

setenv((NLS_("ExportDirectory")), "C:\\Temp\\Export")

you can set the export path (but not the filename). Remember this line of code needs to be executed before you run the include itself.

 

I assume however that you will run into issues with accessing DB and DBE elements in batch-mode, in this case you'll have to edit the do_export_file function itself and substitute all the get(dbe) calls.

Re: Automate HTML export of a module
SamueleMazzoleni - Tue Feb 28 07:50:30 EST 2017

Thanks for the reply, it worked.

I didn't get any problem setting DB element "db_filename" in batch mode.

Here is the line used to set export direcory:

string exportSaveFullPath = exportSavePath goodFileName(fullName(current Module)) ".htm"
set (db_filename, exportSaveFullPath)
do_export_file theDiag

and exportSavePath is a string variable passed from command prompt interface and setted in doors in dxl batch mode.

Now the export automation is fully working.