- Code: Select all
List<Object> texts = getAllElementFromObject(template.getMainDocumentPart(), Text.class);
replacePlaceHolders(texts, mappings);
private static void replacePlaceHolders(List<?> texts,Map<String, String> mappings){
for (Object object : texts) {
Text textElement=(Text)object;
String textToReplace=textElement.getValue();
if(mappings.keySet().contains(textToReplace)){
textElement.setValue(mappings.get(textToReplace));
}
}
}
surprisingly in the above code textElement.getValue(); never returns ${paceholder1}.
below is document.xml , word replaces my place holder ...