Altova UModel 2025

The JScript listing below shows how to generate documentation for the Bank_MultiLanguage.ump file in the UModelExamples folder.

 

This code is available in the sample file ..\UModelExamples\API\JScript\GenerateDoc.js (see also Example Files).

 

// Initialize application's COM object. This will start a new instance of the application and
// return its main COM object. Depending on COM settings, a the main COM object of an already
// running application might be returned.
try {   objUModel = WScript.GetObject("", "UModel.Application");   }
catch(err) {}
 
if( typeof( objUModel ) == "undefined" )
{
  try   {   objUModel = WScript.GetObject("", "UModel_x64.Application")   }
  catch(err)
  {
     WScript.Echo( "Can't access or create UModel.Application" );
     WScript.Quit();
  }
}
 
// if newly started, the application will start without its UI visible. Set it to visible.
objUModel.Visible = true;
 
// Locate examples via USERPROFILE shell variable.
objWshShell = WScript.CreateObject("WScript.Shell");
majorVersionYear = objUModel.MajorVersion + 1998
strExamplesFolder = objWshShell.ExpandEnvironmentStrings("%USERPROFILE%") + "\\Documents\\Altova\\UModel" + majorVersionYear + "\\UModelExamples\\";
 
objDoc = objUModel.OpenDocument(strExamplesFolder + "Bank_MultiLanguage.ump");
 
// generate documentation
dlgs = objUModel.Dialogs;
docDlg = dlgs.GenerateDocumentationDlg;
docDlg.OutputFormat = 0; // ENUMDocumentationOutputFormat.eDocumentationOutputFormat_HTML
 
var myObject = new ActiveXObject("Scripting.FileSystemObject");
strDocOutputFolder = strExamplesFolder + "GeneraredDocFromJScriptExample\\";
 
if (!myObject.FolderExists(strDocOutputFolder))
  myObject.CreateFolder(strDocOutputFolder);
 
strResultFile = strDocOutputFolder + "Bank_MultiLanguage.html";
objDoc.generateDocumentation(docDlg, strResultFile);
 
//objUModel.Visible = false;      // will shutdown application if it has no more COM connections
objUModel.Visible = true;   // will keep application running with UI visible

© 2018-2024 Altova GmbH