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

**URL:** <https://forums.visual-paradigm.com/t/passing-values-from-open-api-to-xml-template-to-be-then-written-to-word-doc-generated/16122>\
**Category:** Plug-in & Open API\
**Tags:** generate-document\
**Created:** [June 5, 2020, 11:22am UTC](https://forums.visual-paradigm.com/t/passing-values-from-open-api-to-xml-template-to-be-then-written-to-word-doc-generated/16122 "2020-06-05T11:22:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalitnagpal](https://avatars.discourse-cdn.com/v2/letter/l/c6cbf5/32.png) [@lalitnagpal](https://forums.visual-paradigm.com/u/lalitnagpal)\
**Post date:** [June 5, 2020, 11:22am UTC](https://forums.visual-paradigm.com/t/passing-values-from-open-api-to-xml-template-to-be-then-written-to-word-doc-generated/16122/1 "2020-06-05T11:22:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![peter.wong](https://forums.visual-paradigm.com/user_avatar/forums.visual-paradigm.com/peter.wong/32/3250_2.png) [@peter.wong](https://forums.visual-paradigm.com/u/peter.wong)\
**Post date:** [June 8, 2020, 8:12am UTC](https://forums.visual-paradigm.com/t/passing-values-from-open-api-to-xml-template-to-be-then-written-to-word-doc-generated/16122/2 "2020-06-08T08:12:01Z")

</div>

as following:

 ![Variable](https://forums.visual-paradigm.com/uploads/default/original/2X/9/9746ad3c15fe268e323197d7d01081dd36b816b1.png)

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

```

---

<div class="post-metadata">

**Author:** ![lalitnagpal](https://avatars.discourse-cdn.com/v2/letter/l/c6cbf5/32.png) [@lalitnagpal](https://forums.visual-paradigm.com/u/lalitnagpal)\
**Post date:** [June 8, 2020, 11:22am UTC](https://forums.visual-paradigm.com/t/passing-values-from-open-api-to-xml-template-to-be-then-written-to-word-doc-generated/16122/3 "2020-06-08T11:22:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![peter.wong](https://forums.visual-paradigm.com/user_avatar/forums.visual-paradigm.com/peter.wong/32/3250_2.png) [@peter.wong](https://forums.visual-paradigm.com/u/peter.wong)\
**Post date:** [June 15, 2020, 6:24am UTC](https://forums.visual-paradigm.com/t/passing-values-from-open-api-to-xml-template-to-be-then-written-to-word-doc-generated/16122/4 "2020-06-15T06:24:33Z")

</div>

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

- `<IterationBlock modelType=... stereotypes=... name=...`
- `<ValueChecker value=...`
- `<Text style=...`  
_etc…_
