Processing checkbox with Map

Hello Team,

Currently i’m setting the checkbox on the basis of tag/title for each SDT field. Is it possible that I pass a Map with key as Tag/Title and corresponding boolean value for each checkbox and then we can set the values at once from the map?

TIA

@nileshmishra You can use XML mapping to bind SDT values from the XML. For example here is a simple XML and code that creates document with SDT mapped to this XML:

<data>
	<checkbox1>1</checkbox1>
	<checkbox2>1</checkbox2>
	<checkbox3>0</checkbox3>
</data>
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add custom XML part.
CustomXmlPart customXml = new CustomXmlPart();
customXml.setData(Files.readAllBytes(Paths.get("C:\\Temp\\data.xml")));
doc.getCustomXmlParts().add(customXml);

// Add checkboxes and set xml mapping.
StructuredDocumentTag sdt1 = new StructuredDocumentTag(doc, SdtType.CHECKBOX, MarkupLevel.INLINE);
sdt1.getXmlMapping().setMapping(customXml, "/data[1]/checkbox1[1]", "");

StructuredDocumentTag sdt2 = new StructuredDocumentTag(doc, SdtType.CHECKBOX, MarkupLevel.INLINE);
sdt2.getXmlMapping().setMapping(customXml, "/data[1]/checkbox2[1]", "");

StructuredDocumentTag sdt3 = new StructuredDocumentTag(doc, SdtType.CHECKBOX, MarkupLevel.INLINE);
sdt3.getXmlMapping().setMapping(customXml, "/data[1]/checkbox3[1]", "");

builder.insertNode(sdt1);
builder.writeln();
builder.insertNode(sdt2);
builder.writeln();
builder.insertNode(sdt3);

doc.save("C:\\Temp\\out.docx");

here is the output: out.docx (8.5 KB)