Passing values from Open API to XML Template to be then written to Word Doc Generated

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) );

as following:

				// variable: specifiedModelType
				IRDTemplateVariable variable = IModelElementFactory.instance().createRDTemplateVariable();
				variable.setName("${specifiedModelType}");
				variable.setValue(IModelElementFactory.MODEL_TYPE_ARCHI_MATE_PLATEAU);
				variable.setFollowGlobal(false);
				currentIRDOOTemplate.addVariable(variable);
1 Like

I tried writing the value in ${specifiedModelType} as part of a header for example:

<Text style="Heading3">Listing for ${specifiedModelType}</Text>

that didn’t work, would it work only as a part of the IterationBlocks etc.

Sorry, the ${…} is not supported in <Text>...</Text>
It is only supported in

  • <IterationBlock modelType=... stereotypes=... name=...
  • <ValueChecker value=...
  • <Text style=...
    etc…