I am using the Open API code to apply a template ( DCTL XML template ) and generate a doc from scratch. My need is to supply some value from Java code to the XML template which can then write to my word document generated. I have created and applied a template in below code as we can see.
IReportDiagramUIModel reportDiagramUIModel = (IReportDiagramUIModel) diagramManager.createDiagram( IDiagramTypeConstants.DIAGRAM_TYPE_REPORT_DIAGRAM );
reportDiagramDetails = reportDiagramDetailsContainer.createReportDiagramDetails();
reportDiagramUIModel.setGenericXMLElementAddress( reportDiagramDetails.getAddress() );
IReportDiagramOption reportDiagramOption = IModelElementFactory.instance().createReportDiagramOption();
reportDiagramOption.setUseWordDocumnentTemplate( true );
reportDiagramOption.setWordDocumnentTemplatePath( coverPagePath );
reportDiagramDetails.setReportDiagramOption( reportDiagramOption );
if (reportDiagramOption.getReportDocInfo() == null) {
reportDiagramOption.setReportDocInfo( reportDiagramOption.createReportDocInfo() );
}
docInfo.setTitle( project.getName() );
reportDiagramDetails.addRDPageBreakTemplate( IModelElementFactory.instance().createRDPageBreakTemplate() );
IRDOOTemplate currentIRDOOTemplate = reportDiagramDetails.createRDOOTemplate();
currentIRDOOTemplate.setTemplateURI(templateName);
currentIRDOOTemplate.setSourceType(1);
currentIRDOOTemplate.setSourceId(archiMateDiagram.getId());
ICompositeValueSpecification stateValueSpec = IModelElementFactory.instance().createCompositeValueSpecification();
stateValueSpec.setName(archiMateDiagram.getId());
stateValueSpec.setValue(layers);
currentIRDOOTemplate.addLayerFilter(stateValueSpec);
reportDiagramDetails.addTemplate(currentIRDOOTemplate);
reportDiagramUIModel.setName( name.toUpperCase() );
ApplicationManager.instance().getDocumentationManager().generateDocComposerWord( reportDiagramUIModel, new File( docName ), null);
Desktop.getDesktop().open( new File(docName) );