Script that loops through modules in current folder and exports to separate Word documents using RPELight

Hello,

I am working on a DXL script that allows me to automate my current DOORS Module exporting process. I would like to run the script inside a folder, and it should go through each DOORS module in the folder and export it to Word using RPELight. I currently have the following code, and it is throwing the attached errors ( I am not sure where to begin debugging). I pieced together this code by using a few other posts on here as I am not very familiar with DXL, so any help with understanding what I am doing wrong would be greatly appreciated!

Code:

bool confirm (string s) { print "Confirmed: " s "\n"; return true }
void ack (string s) {print "Ack: " s "\n" }
void errorBox (string s) {print "Error: " s "\n"; }
void warningBox (string s) {print "Warning: " s "\n"; }
void acknowledge (string s) {print "Acknowledge: " s "\n"  }
void infobox (string s) {print "InfoBox: " s "\n" }
void info (string s) {print "Info: " s "\n" }

DB tmpDB = null
DBE tm = null

// Notice that show will only store the variable now.  
void oldshow(DB x){show x}
void show(DB x){tmpDB=x}

#include <standard/export/RPE_Light/DoorsExport.inc>

void processFolder(Folder currentFolder)
{
    Item currentItem
    
    for currentItem in currentFolder do
    {

        if (isDeleted(currentItem)) 
        {
            continue
        }

        if (type(currentItem) == "Formal")
        {
            Module m = null

            m = read(fullName(currentItem), false)

            if (null m)
            {
                print("ERROR opening module " fullName(currentItem) "\n")
            }

            else
            {

                // create the dialog but do not show it yet
                showRPEExportDialog(LS_("String_Export_To_Word", NLSTEMP_("Export to Word")), (NLS_("doc")), (NLS_(".doc")))

                // add a timer to it, it will 'press' the button now after we do show ...
                void hitButtonCB(DBE x) 
                {     
                    stopTimer tm; 
                    exportCB(null)
                }

                tm = timer(tmpDB, 0.2, hitButtonCB, "Hit Button"); 
                // realize the dialog box, so we can apply the settings ....
                realize tmpDB;
                
                // apply the settings
                set(includeTablesToggle,true)
                setenv("EXPORTDIRECTORY", "C:\\...\\...")
                set(templateFile,"C:\\...\\...\\TemplateFile.DTA")
                // set(advancedTemplateLabel,"C:\..\\Styles.dotx")
                // show the dialog, timer will kick in and press our button
                print "About to enter message loop ...\n";
                oldshow tmpDB

                print(fullName(currentItem) " ok\n") 
            }

            close(m)       
        }
    }
}

processFolder(current Folder)

 

Errors:

"DXL halted with a run-time error"

-R-E- DXL: <standard/export/RPE_Light/DoorsExport.inc:2008> Cannot create a dialog box with hidden module as parent
Backtrace:
        <Line:45> 
        <Line:75> 
-R-I- DXL: <Line:0> DXL maximum instruction count reached (infinite loop?).  Extend limit with pragma runLim,<count>.
Backtrace:
        <Line:45> 
        <Line:75> 

 

Thanks!

Rahul

 


Rahul.Y - Mon Jul 23 16:22:16 EDT 2018

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
Mathias Mamsch - Tue Jul 24 05:01:51 EDT 2018

From the error message it seems you need to open the module visible, because RPE will parent the dialog to the current module. But there is a more serious problem here:

The script you posted uses a trick, to be able to invoke RPE. RPE will call back over COM into DOORS, so if a DXL script is active, this will not work. Therefore the script uses "Show" to show the dialog box and a timer to invoke the RPE export, but that means, that the DXL effectively ends there. Therefore calling the code in a loop like you did will not work.

Instead you should look in the forum for the code to launch RPE directly. There was a trick involved: in the post the author overrided the "system" call, so that RPE was not executed, to get the actual java commandline. Once you have the commandline, you can simple invoke JAVA yourself. But again, you might need to be careful, that no DXL script is active when the java actually calls back into DOORS. Therefore you would again need a GUI and control the projects / module export flow from a timer. Difficult. You are sure that you need DXL for that? Could you not simply collect the config data from DOORS and invoke an external TOOL in some scripting language, that will do the java calls one by one? Regards, Mathias

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
PekkaMakinen - Tue Jul 24 07:32:02 EDT 2018

Mathias Mamsch - Tue Jul 24 05:01:51 EDT 2018

From the error message it seems you need to open the module visible, because RPE will parent the dialog to the current module. But there is a more serious problem here:

The script you posted uses a trick, to be able to invoke RPE. RPE will call back over COM into DOORS, so if a DXL script is active, this will not work. Therefore the script uses "Show" to show the dialog box and a timer to invoke the RPE export, but that means, that the DXL effectively ends there. Therefore calling the code in a loop like you did will not work.

Instead you should look in the forum for the code to launch RPE directly. There was a trick involved: in the post the author overrided the "system" call, so that RPE was not executed, to get the actual java commandline. Once you have the commandline, you can simple invoke JAVA yourself. But again, you might need to be careful, that no DXL script is active when the java actually calls back into DOORS. Therefore you would again need a GUI and control the projects / module export flow from a timer. Difficult. You are sure that you need DXL for that? Could you not simply collect the config data from DOORS and invoke an external TOOL in some scripting language, that will do the java calls one by one? Regards, Mathias

Sometime ago I took O. Wilkop's solution in post https://www.ibm.com/developerworks/community/forums/html/topic?id=645237e1-18f1-45d2-8d36-2a4f337f7479 as a starting point and developed our internal solution based on that. This is code which we used - it will produce an export on the desktop for the current module. Do not know if this is easy to modify to produce many export documents, as the results of this script are actually processed by Java. Note also that our environment is DOORS 9.6.0.3 and the file paths refer to our installation, might need changes.

 

// Export module to PDF through RPE / Java
 
pragma runLim, 0
 
// Where the RPE template is located
const string TemplateFilePath = "C:\\Temp\\doorsWord.dta"
// Output format, Word / PDF
const string OutputFormat = "Word"
// View to be used in modules
const string ExportView = "Export"
// Where to save the file (user's desktop)
const string SaveTo = (getenv("USERPROFILE")) "\\Desktop\\"
 
Module m = current
string VerNo = "1.00"
string ModuleName = ""
if (null m)
  {
ack "Please run this script from a open module - halting"
halt
  }
else ModuleName = fullName m
 
string TempTo = (getenv("USERPROFILE")) "\\AppData\\Local\\Temp\\"
string DOORSHome = (getenv("DOORSHOME"))
string DOORSData = (getenv("DOORSDATA"))
// A random number to give unique name to the XML output
int rnd =  random(10000000)
string TempXML = TempTo "rpe_config_" rnd ".xml"
 
Stream OutputXML = write TempXML
 
string SystemCommand = "\"" DOORSHome "ibm_jre70\\jre\\bin\\javaw.exe\" -Dcom.ibm.rational.rpe.doors.home=\"" DOORSHome "bin\\doors.exe\" -Dcom.ibm.rational.rpe.doors.data=\"" DOORSData "\" -cp \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\" -jar \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\\DOORS_rpe_export.jar\" \"" TempXML "\""
string XMLstring = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" //-
"<parameters>\n" //-
    "<outputPath>" SaveTo "</outputPath>\n" //-
    "<outputFormats>" OutputFormat "</outputFormats>\n" //-
    "<modulePath>" ModuleName "</modulePath>\n" //-
    "<view>" ExportView "</view>\n" //-
    "<moduleBaseline>Current</moduleBaseline>\n" //-
    "<rpeTemplatePath>" TemplateFilePath "</rpeTemplatePath>\n" //-
    "<rpeHome>" DOORSHome "lib\\dxl\\standard\\export\\RPE_light</rpeHome>\n" //-
    "<rpeDoorsVer>Created by IBM Rational DOORS 9.6</rpeDoorsVer>\n" //-
    "<rpeDateTimePattern>yyyy-MM-dd HH:mm:ss</rpeDateTimePattern>\n" //-
    "<rpeExportDate>2018</rpeExportDate>\n" //-
    "<rpeIncludeEmptyAttrs>false</rpeIncludeEmptyAttrs>\n" //-
    "<rpeIncTables>true</rpeIncTables>\n" //-
    "<DOORS_preserveDOORSTableProperties>true</DOORS_preserveDOORSTableProperties>\n" //-
    "<rpeUseViewName>false</rpeUseViewName>\n" //-
    "<rpeFooter>none</rpeFooter>\n" //-
    "<export>true</export>\n" //-
"</parameters>\n"
 
// MAIN ----------------------------------------------------
if (!confirm("This script will output a PDF format export of the current module.\nThe output is done through Java system, so it will take some time - \nplease wait until the PDF file has been created to your desktop.\n\nPress Confirm to continue or Cancel\n\nVersion " VerNo "")) halt
 
if (canOpenFile(TempXML,true))
   {
OutputXML << XMLstring
flush OutputXML
   }
if (!null OutputXML) close OutputXML
 
system SystemCommand
 

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
Rahul.Y - Tue Jul 24 10:31:14 EDT 2018

Mathias Mamsch - Tue Jul 24 05:01:51 EDT 2018

From the error message it seems you need to open the module visible, because RPE will parent the dialog to the current module. But there is a more serious problem here:

The script you posted uses a trick, to be able to invoke RPE. RPE will call back over COM into DOORS, so if a DXL script is active, this will not work. Therefore the script uses "Show" to show the dialog box and a timer to invoke the RPE export, but that means, that the DXL effectively ends there. Therefore calling the code in a loop like you did will not work.

Instead you should look in the forum for the code to launch RPE directly. There was a trick involved: in the post the author overrided the "system" call, so that RPE was not executed, to get the actual java commandline. Once you have the commandline, you can simple invoke JAVA yourself. But again, you might need to be careful, that no DXL script is active when the java actually calls back into DOORS. Therefore you would again need a GUI and control the projects / module export flow from a timer. Difficult. You are sure that you need DXL for that? Could you not simply collect the config data from DOORS and invoke an external TOOL in some scripting language, that will do the java calls one by one? Regards, Mathias

Mathias,

Ah, thank you for the clarification; I will build off of the code sent by PekkaMakinen.

I wanted to get this done in DXL because I was tasked with automating our exporting process for other users, and these users access DOORS through Citrix. Furthermore, when they open Citrix to access DOORS, they are given access to only DOORS and no other program on the server.  I am unsure about how to deal with writing a batch script (for example) that makes the Java calls on the super locked down version of Citrix, so I am planning to stick with DXL.

You mentioned that I might be able to make this work using a GUI and a timer; I've got a couple of questions regarding this:

  1. When you said that no DXL script should be active when the Java script calls back to DOORS, how exactly would that problem be solved using a timer?
  2. What is the role of the suggested GUI specifically? If it is to select the modules to be exported, there isn't a need for that because I would like for the script to export all modules in a folder.

 

PekkaMakinen,

Thanks for uploading your code! I will try to get it to work on my machine and see if I can extend it by making it run on multiple modules in one execution.

 

EDIT: I seem to be getting an error saying "DOORS Report: Create Process Failed" when I run PekkaMakinen's code. I removed my directory paths in the following code before posting here, by the way:

// Export module to Word through RPE / Java
 
pragma runLim, 0

// Where the RPE template is located
const string TemplateFilePath = "C:\\....DTA"
// Where to save the file
const string SaveTo = "C:\\..."
// RPE Word Template location
const string RPEStylesSheet = "C:\\....dotx"
// View to be used in modules
const string ExportView = "ExportView"
// Output format, Word / PDF
const string OutputFormat = "Word"
// Current Date
const string CurrentDate = stringOf( (dateAndTime today(), "yyyy MM dd") )

Module m = current
string VerNo = "1.00"
string ModuleName = ""
if (null m)
{
    ack "Please run this script from a open module - halting"
    halt
}
else ModuleName = fullName m
 
string TempTo = (getenv("USERPROFILE")) "\\AppData\\Local\\Temp\\"
string DOORSHome = (getenv("DOORSHOME"))
string DOORSData = (getenv("DOORSDATA"))
// A random number to give unique name to the XML output
int rnd =  random(10000000)
string TempXML = TempTo "rpe_config_" rnd ".xml"
 
Stream OutputXML = write TempXML
 
string SystemCommand = "\"" DOORSHome "ibm_jre70\\jre\\bin\\javaw.exe\" -Dcom.ibm.rational.rpe.doors.home=\"" DOORSHome "bin\\doors.exe\" -Dcom.ibm.rational.rpe.doors.data=\"" DOORSData "\" -cp \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\" -jar \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\\DOORS_rpe_export.jar\" \"" TempXML "\""
string XMLstring = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" //-
"<parameters>\n" //-
    "<outputPath>"SaveTo"</outputPath>\n" //-
    "<outputFormats>"OutputFormat"</outputFormats>\n" //-
    "<modulePath>"ModuleName"</modulePath>\n" //-
    "<view>"ExportView"</view>\n" //-
    "<moduleBaseline>Current</moduleBaseline>\n" //-
    "<rpeTemplatePath>"TemplateFilePath"</rpeTemplatePath>\n" //-
    "<rpeHome>"DOORSHome"lib\\dxl\\standard\\export\\RPE_light</rpeHome>\n"  //-
    "<rpeDoorsVer>Created by IBM Rational DOORS 9.6</rpeDoorsVer>\n" //-
    "<rpeDateTimePattern>yyyy-MM-dd HH:mm:ss</rpeDateTimePattern>\n" //-
    "<rpeExportDate>"CurrentDate"</rpeExportDate>\n" //-
    "<rpeIncludeEmptyAttrs>false</rpeIncludeEmptyAttrs>\n" //-
    "<rpeIncTables>true</rpeIncTables>\n" //-
    "<DOORS_preserveDOORSTableProperties>true</DOORS_preserveDOORSTableProperties>\n" //-
    "<rpeUseViewName>false</rpeUseViewName>\n" //-
    "<rpeFooter>"ModuleName"</rpeFooter>\n" //-
    "<export>true</export>\n" //-
    "<OleAsImage>true</OleAsImage>\n" //-
    "<rpeWordTemplate>"RPEStylesSheet"</rpeWordTemplate>\n" //-
"</parameters>\n"
 
// MAIN ----------------------------------------------------
if (!confirm("This script will output a Word export of the current module.\nThe output is done through Java system, so it will take some time - \nplease wait until the Word file has been created to the export folder.\n\nPress Confirm to continue or Cancel\n\nVersion " VerNo "")) halt
 
if (canOpenFile(TempXML,true))
{
    OutputXML << XMLstring
    flush OutputXML
}
if (!null OutputXML) close OutputXML
 
system SystemCommand

 

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
PekkaMakinen - Wed Jul 25 01:46:13 EDT 2018

Rahul.Y - Tue Jul 24 10:31:14 EDT 2018

Mathias,

Ah, thank you for the clarification; I will build off of the code sent by PekkaMakinen.

I wanted to get this done in DXL because I was tasked with automating our exporting process for other users, and these users access DOORS through Citrix. Furthermore, when they open Citrix to access DOORS, they are given access to only DOORS and no other program on the server.  I am unsure about how to deal with writing a batch script (for example) that makes the Java calls on the super locked down version of Citrix, so I am planning to stick with DXL.

You mentioned that I might be able to make this work using a GUI and a timer; I've got a couple of questions regarding this:

  1. When you said that no DXL script should be active when the Java script calls back to DOORS, how exactly would that problem be solved using a timer?
  2. What is the role of the suggested GUI specifically? If it is to select the modules to be exported, there isn't a need for that because I would like for the script to export all modules in a folder.

 

PekkaMakinen,

Thanks for uploading your code! I will try to get it to work on my machine and see if I can extend it by making it run on multiple modules in one execution.

 

EDIT: I seem to be getting an error saying "DOORS Report: Create Process Failed" when I run PekkaMakinen's code. I removed my directory paths in the following code before posting here, by the way:

// Export module to Word through RPE / Java
 
pragma runLim, 0

// Where the RPE template is located
const string TemplateFilePath = "C:\\....DTA"
// Where to save the file
const string SaveTo = "C:\\..."
// RPE Word Template location
const string RPEStylesSheet = "C:\\....dotx"
// View to be used in modules
const string ExportView = "ExportView"
// Output format, Word / PDF
const string OutputFormat = "Word"
// Current Date
const string CurrentDate = stringOf( (dateAndTime today(), "yyyy MM dd") )

Module m = current
string VerNo = "1.00"
string ModuleName = ""
if (null m)
{
    ack "Please run this script from a open module - halting"
    halt
}
else ModuleName = fullName m
 
string TempTo = (getenv("USERPROFILE")) "\\AppData\\Local\\Temp\\"
string DOORSHome = (getenv("DOORSHOME"))
string DOORSData = (getenv("DOORSDATA"))
// A random number to give unique name to the XML output
int rnd =  random(10000000)
string TempXML = TempTo "rpe_config_" rnd ".xml"
 
Stream OutputXML = write TempXML
 
string SystemCommand = "\"" DOORSHome "ibm_jre70\\jre\\bin\\javaw.exe\" -Dcom.ibm.rational.rpe.doors.home=\"" DOORSHome "bin\\doors.exe\" -Dcom.ibm.rational.rpe.doors.data=\"" DOORSData "\" -cp \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\" -jar \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\\DOORS_rpe_export.jar\" \"" TempXML "\""
string XMLstring = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" //-
"<parameters>\n" //-
    "<outputPath>"SaveTo"</outputPath>\n" //-
    "<outputFormats>"OutputFormat"</outputFormats>\n" //-
    "<modulePath>"ModuleName"</modulePath>\n" //-
    "<view>"ExportView"</view>\n" //-
    "<moduleBaseline>Current</moduleBaseline>\n" //-
    "<rpeTemplatePath>"TemplateFilePath"</rpeTemplatePath>\n" //-
    "<rpeHome>"DOORSHome"lib\\dxl\\standard\\export\\RPE_light</rpeHome>\n"  //-
    "<rpeDoorsVer>Created by IBM Rational DOORS 9.6</rpeDoorsVer>\n" //-
    "<rpeDateTimePattern>yyyy-MM-dd HH:mm:ss</rpeDateTimePattern>\n" //-
    "<rpeExportDate>"CurrentDate"</rpeExportDate>\n" //-
    "<rpeIncludeEmptyAttrs>false</rpeIncludeEmptyAttrs>\n" //-
    "<rpeIncTables>true</rpeIncTables>\n" //-
    "<DOORS_preserveDOORSTableProperties>true</DOORS_preserveDOORSTableProperties>\n" //-
    "<rpeUseViewName>false</rpeUseViewName>\n" //-
    "<rpeFooter>"ModuleName"</rpeFooter>\n" //-
    "<export>true</export>\n" //-
    "<OleAsImage>true</OleAsImage>\n" //-
    "<rpeWordTemplate>"RPEStylesSheet"</rpeWordTemplate>\n" //-
"</parameters>\n"
 
// MAIN ----------------------------------------------------
if (!confirm("This script will output a Word export of the current module.\nThe output is done through Java system, so it will take some time - \nplease wait until the Word file has been created to the export folder.\n\nPress Confirm to continue or Cancel\n\nVersion " VerNo "")) halt
 
if (canOpenFile(TempXML,true))
{
    OutputXML << XMLstring
    flush OutputXML
}
if (!null OutputXML) close OutputXML
 
system SystemCommand

 

Have you checked the paths and files names that they correspond to your DOORS installation?

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
Mathias Mamsch - Wed Jul 25 04:51:23 EDT 2018

Rahul.Y - Tue Jul 24 10:31:14 EDT 2018

Mathias,

Ah, thank you for the clarification; I will build off of the code sent by PekkaMakinen.

I wanted to get this done in DXL because I was tasked with automating our exporting process for other users, and these users access DOORS through Citrix. Furthermore, when they open Citrix to access DOORS, they are given access to only DOORS and no other program on the server.  I am unsure about how to deal with writing a batch script (for example) that makes the Java calls on the super locked down version of Citrix, so I am planning to stick with DXL.

You mentioned that I might be able to make this work using a GUI and a timer; I've got a couple of questions regarding this:

  1. When you said that no DXL script should be active when the Java script calls back to DOORS, how exactly would that problem be solved using a timer?
  2. What is the role of the suggested GUI specifically? If it is to select the modules to be exported, there isn't a need for that because I would like for the script to export all modules in a folder.

 

PekkaMakinen,

Thanks for uploading your code! I will try to get it to work on my machine and see if I can extend it by making it run on multiple modules in one execution.

 

EDIT: I seem to be getting an error saying "DOORS Report: Create Process Failed" when I run PekkaMakinen's code. I removed my directory paths in the following code before posting here, by the way:

// Export module to Word through RPE / Java
 
pragma runLim, 0

// Where the RPE template is located
const string TemplateFilePath = "C:\\....DTA"
// Where to save the file
const string SaveTo = "C:\\..."
// RPE Word Template location
const string RPEStylesSheet = "C:\\....dotx"
// View to be used in modules
const string ExportView = "ExportView"
// Output format, Word / PDF
const string OutputFormat = "Word"
// Current Date
const string CurrentDate = stringOf( (dateAndTime today(), "yyyy MM dd") )

Module m = current
string VerNo = "1.00"
string ModuleName = ""
if (null m)
{
    ack "Please run this script from a open module - halting"
    halt
}
else ModuleName = fullName m
 
string TempTo = (getenv("USERPROFILE")) "\\AppData\\Local\\Temp\\"
string DOORSHome = (getenv("DOORSHOME"))
string DOORSData = (getenv("DOORSDATA"))
// A random number to give unique name to the XML output
int rnd =  random(10000000)
string TempXML = TempTo "rpe_config_" rnd ".xml"
 
Stream OutputXML = write TempXML
 
string SystemCommand = "\"" DOORSHome "ibm_jre70\\jre\\bin\\javaw.exe\" -Dcom.ibm.rational.rpe.doors.home=\"" DOORSHome "bin\\doors.exe\" -Dcom.ibm.rational.rpe.doors.data=\"" DOORSData "\" -cp \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\" -jar \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\\DOORS_rpe_export.jar\" \"" TempXML "\""
string XMLstring = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" //-
"<parameters>\n" //-
    "<outputPath>"SaveTo"</outputPath>\n" //-
    "<outputFormats>"OutputFormat"</outputFormats>\n" //-
    "<modulePath>"ModuleName"</modulePath>\n" //-
    "<view>"ExportView"</view>\n" //-
    "<moduleBaseline>Current</moduleBaseline>\n" //-
    "<rpeTemplatePath>"TemplateFilePath"</rpeTemplatePath>\n" //-
    "<rpeHome>"DOORSHome"lib\\dxl\\standard\\export\\RPE_light</rpeHome>\n"  //-
    "<rpeDoorsVer>Created by IBM Rational DOORS 9.6</rpeDoorsVer>\n" //-
    "<rpeDateTimePattern>yyyy-MM-dd HH:mm:ss</rpeDateTimePattern>\n" //-
    "<rpeExportDate>"CurrentDate"</rpeExportDate>\n" //-
    "<rpeIncludeEmptyAttrs>false</rpeIncludeEmptyAttrs>\n" //-
    "<rpeIncTables>true</rpeIncTables>\n" //-
    "<DOORS_preserveDOORSTableProperties>true</DOORS_preserveDOORSTableProperties>\n" //-
    "<rpeUseViewName>false</rpeUseViewName>\n" //-
    "<rpeFooter>"ModuleName"</rpeFooter>\n" //-
    "<export>true</export>\n" //-
    "<OleAsImage>true</OleAsImage>\n" //-
    "<rpeWordTemplate>"RPEStylesSheet"</rpeWordTemplate>\n" //-
"</parameters>\n"
 
// MAIN ----------------------------------------------------
if (!confirm("This script will output a Word export of the current module.\nThe output is done through Java system, so it will take some time - \nplease wait until the Word file has been created to the export folder.\n\nPress Confirm to continue or Cancel\n\nVersion " VerNo "")) halt
 
if (canOpenFile(TempXML,true))
{
    OutputXML << XMLstring
    flush OutputXML
}
if (!null OutputXML) close OutputXML
 
system SystemCommand

 

Regarding the timer: A GUI solves this problem, because once you call "show(DB)" inside a DXL, the DXL effectively ends, but the DXL Context will be kept alive, if the script has defined some active triggers or if the script launched a GUI. The DXL script will then be served with GUI events inside the windows event loop of the DOORS client, e.g. if you click a button a callback inside that DXL context will be invoked but also if a timer event happens. While the event is processed of course no other DXL can run (as only one DXL script can run at the time), but once the event is processed, DXL execution is ended again.

You can use this approach to automate your script in the following way:

- Loop through the Folders / Projects you want to export and store the necessary information in a skip list

- Use a timer that works like this: 

    - if there is no current export, start one

    - regularly check for the export results of the current export, if the export is done, collect the results, start the next one.

 

This way you try the RPE export not getting in the way of the current DXL script. When RPE invokes a DXL script to read the data from DOORS your timer will not execute. This seems to be the only way, on how to invoke multiple RPE exports from the same DXL script.

Regards, Mathias

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
Rahul.Y - Wed Jul 25 15:40:38 EDT 2018

PekkaMakinen - Wed Jul 25 01:46:13 EDT 2018

Have you checked the paths and files names that they correspond to your DOORS installation?

PekkaMakinen,

Yes. I manually exported a module and checked for differences between the XML file that was generated and the one inside the dxl script. I even ran the script once with the directories hard coded into it but to no avail. I also confirmed that the xml file is being created with the right contents and in the right place.

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
Rahul.Y - Wed Jul 25 15:49:50 EDT 2018

Mathias Mamsch - Wed Jul 25 04:51:23 EDT 2018

Regarding the timer: A GUI solves this problem, because once you call "show(DB)" inside a DXL, the DXL effectively ends, but the DXL Context will be kept alive, if the script has defined some active triggers or if the script launched a GUI. The DXL script will then be served with GUI events inside the windows event loop of the DOORS client, e.g. if you click a button a callback inside that DXL context will be invoked but also if a timer event happens. While the event is processed of course no other DXL can run (as only one DXL script can run at the time), but once the event is processed, DXL execution is ended again.

You can use this approach to automate your script in the following way:

- Loop through the Folders / Projects you want to export and store the necessary information in a skip list

- Use a timer that works like this: 

    - if there is no current export, start one

    - regularly check for the export results of the current export, if the export is done, collect the results, start the next one.

 

This way you try the RPE export not getting in the way of the current DXL script. When RPE invokes a DXL script to read the data from DOORS your timer will not execute. This seems to be the only way, on how to invoke multiple RPE exports from the same DXL script.

Regards, Mathias

Mathias,

That makes a lot of sense, and I will follow the outline you suggested. Thank you for the help!

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
PekkaMakinen - Thu Jul 26 01:00:40 EDT 2018

Rahul.Y - Wed Jul 25 15:40:38 EDT 2018

PekkaMakinen,

Yes. I manually exported a module and checked for differences between the XML file that was generated and the one inside the dxl script. I even ran the script once with the directories hard coded into it but to no avail. I also confirmed that the xml file is being created with the right contents and in the right place.

Hi, if you want to continue with this I would recommend to run the corresponding command as the SystemCommand string from the command line directly (not from DXL) to see what is the response from the OS.

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
Rahul.Y - Thu Jul 26 14:18:21 EDT 2018

PekkaMakinen - Thu Jul 26 01:00:40 EDT 2018

Hi, if you want to continue with this I would recommend to run the corresponding command as the SystemCommand string from the command line directly (not from DXL) to see what is the response from the OS.

Hello,

Thank you for that suggestion! It led me to realize that my javaw.exe is not in the following directory for some reason.

DOORSHome "ibm_jre70\\jre\\bin\\javaw.exe\

My DOORSHome looks like this:

C:\Program Files\IBM\Rational\DOORS\9.6\

The javaw.exe file is actually located in (the x86 program files folder):

C:\Program Files (
x86)\IBM\Rational\DOORS\9.6\ibm_jre70\jre\bin

Your script now works on my machine. I'll now get working on implementing it into the design suggested by Mathias.

 

Re: Script that loops through modules in current folder and exports to separate Word documents using RPELight
Rahul.Y - Wed Aug 01 10:19:29 EDT 2018

For future readers:

 

I realized that our Citrix Server is not as restricted as I initially thought it was, so I found a different way approach this task. It is similar to what Mathias has suggested.

  1. Write a dxl script that iterates through the modules in a given folder, and generates XML spec files for each of them in the output folder.
  2. Before exiting, the dxl script will write the cmd command to a text file in the output folder and call the following executable with the output folder directory as an argument
  3. This executable should also be placed in the output folder. Its job is to go through all of the XML spec files generated and make the RPE Light Export command line calls for each; then, it will delete the text and xml files generated. (Note: I created this exe file by writing a python script that does these things and generated a standalone executable using it. Mainly because I am much more comfortable with scripting in Python)

Here is my DXL Script:

// Export module to Word through RPE / Java

pragma runLim, 0

// Where the RPE template is located
const string TemplateFilePath = ""
// Where to save the file
const string SaveTo = ""
// RPE Word Template location
const string RPEStylesSheet = ""
// View to be used in modules
const string ExportView = ""
// Output format, Word / PDF
const string OutputFormat = "Word"
// Current Date
const string CurrentDate = stringOf( (dateOnly today()), "yyyy MM dd" )
// Text file containing RPE Light system commands
const string fName= SaveTo "\\sysCommand.txt"

Item currentItem
bool firstModule = false
string ModuleName = ""
string TempTo = SaveTo "\\"
string DOORSHome = (getenv("DOORSHOME"))
string DOORSData = (getenv("DOORSDATA"))
int rnd = 1
string TempXML = ""
string SystemCommand =  "\"C:\\Program Files (x86)\\IBM\\Rational\\DOORS\\9.6\\ibm_jre70\\jre\\bin\\javaw.exe\" -Dcom.ibm.rational.rpe.doors.home=\"" DOORSHome "bin\\doors.exe\" -Dcom.ibm.rational.rpe.doors.data=\"" DOORSData "\" -cp \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\" -jar \"" DOORSHome "lib\\dxl\\standard\\export\\RPE_light\\lib\\DOORS_rpe_export.jar\" \" TEMP_XML_DIR \""
string XMLstring = ""
Module m = null
Module cm = null

for currentItem in (current Folder) do
{
    if (isDeleted(currentItem))
    {
        continue
    }

    if (type(currentItem) == "Formal")
    {
        m = read(fullName(currentItem), false)
        Module cm = current
        ModuleName = fullName cm
        TempXML = TempTo "rpe_config_" rnd ".xml"

        Stream OutputXML = write TempXML

        XMLstring = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" //-
        "<parameters>\n" //-
            "<outputPath>"SaveTo"</outputPath>\n" //-
            "<outputFormats>"OutputFormat"</outputFormats>\n" //-
            "<modulePath>"ModuleName"</modulePath>\n" //-
            "<view>"ExportView"</view>\n" //-
            "<moduleBaseline>Current</moduleBaseline>\n" //-
            "<rpeTemplatePath>"TemplateFilePath"</rpeTemplatePath>\n" //-
            "<rpeHome>"DOORSHome"lib\\dxl\\standard\\export\\RPE_light</rpeHome>\n"  //-
            "<rpeDoorsVer>Created by IBM Rational DOORS 9.6</rpeDoorsVer>\n" //-
            "<rpeDateTimePattern>yyyy-MM-dd HH:mm:ss</rpeDateTimePattern>\n" //-
            "<rpeExportDate>"CurrentDate"</rpeExportDate>\n" //-
            "<rpeIncludeEmptyAttrs>false</rpeIncludeEmptyAttrs>\n" //-
            "<rpeIncTables>true</rpeIncTables>\n" //-
            "<DOORS_preserveDOORSTableProperties>true</DOORS_preserveDOORSTableProperties>\n" //-
            "<rpeUseViewName>false</rpeUseViewName>\n" //-
            "<rpeFooter>"ModuleName"</rpeFooter>\n" //-
            "<export>true</export>\n" //-
            "<OleAsImage>true</OleAsImage>\n" //-
        "</parameters>\n"

        if (canOpenFile(TempXML,true))
        {
            OutputXML << XMLstring
            flush OutputXML
        }
        if (!null OutputXML) close OutputXML
        close(m)

        rnd += 1
    }

}
Stream writtingBuf = write(fName)
writtingBuf <<  SystemCommand
close(writtingBuf)

print "Running " SaveTo "\\pythonExporter.exe"
system SaveTo "\\pythonExporter.exe " SaveTo

Here is the python script I used to create the executable script:

# -*- coding: utf-8 -*-
DESCRIPTION = "\nThis script will loop through .xml files that are in the same \nfolder as this executable and export the corresponding DOORS modules\n"

import os
import sys
import shutil
import win32com.client as win32

try:
        # change the current directory to that of the output folder which was passed in
        os.chdir(sys.argv[1])

        # read the system command txt file 
        sysCommand = open("sysCommand.txt")
        rpe_export_templ =sysCommand.readline().strip()
        sysCommand.close()

        # store the current absolute path
        current_abs_path = os.path.abspath(os.path.dirname(sys.argv[0]))

        # loop throgh all files in the current directory
        for file in os.listdir("."):

                #if the current file is a spec xml file, run the command
                if file.startswith("rpe_config_") and file.endswith(".xml") :
                        file_path = "\\\\"+os.path.join(current_abs_path, file).replace("\\", "\\\\")+"\\\\"
                        current_command = rpe_export_templ.replace(" TEMP_XML_DIR ", file_path)

                        print("")
                        print("Exporting " + file)
                        os.system("\""+current_command+"\"")

        # go through the directory and delete all of the temporary files created
        for item in os.listdir("."):
                if item.startswith("rpe_config_") or item.endswith("sysCommand.txt"):
                        os.remove(os.path.join(current_abs_path, item))

except Exception as e:
        print("An error has occurred: ")
        print(str(e))

        # Asks for an input so that the command prompt does not exit automatically 
        Stop = raw_input()