Element propertyElem = UtilXml.addChildElement(resourceElem, "property", resourceDocument);
propertyElem.setAttribute("key", StringUtil.fromHtmlToSpecialChars(labelInfo.getLabelKey(), true, true, false));
if (UtilValidate.isNotEmpty(labelInfo.getLabelKeyComment())) {
Comment labelKeyComment = resourceDocument.createComment(StringUtil.fromHtmlToSpecialChars(labelInfo.getLabelKeyComment(), true, true, false));
Node parent = propertyElem.getParentNode();
parent.insertBefore(labelKeyComment, propertyElem);
}
for (String localeFound : localesFound) {
LabelValue labelValue = labelInfo.getLabelValue(localeFound);
String valueString = null;
if (labelValue != null) {
valueString = labelValue.getLabelValue();
}
if (UtilValidate.isNotEmpty(valueString)) {
valueString = StringUtil.fromHtmlToSpecialChars(valueString, true, true, true);
Element valueElem = UtilXml.addChildElementValue(propertyElem, "value", valueString, resourceDocument);;
valueElem.setAttribute("xml:lang", localeFound);
if (valueString.trim().length() == 0) {
valueElem.setAttribute("xml:space", "preserve");
}
if (UtilValidate.isNotEmpty(labelValue.getLabelComment())) {
Comment labelComment = resourceDocument.createComment(StringUtil.fromHtmlToSpecialChars(labelValue.getLabelComment(), true, true, false));
Node parent = valueElem.getParentNode();
parent.insertBefore(labelComment, valueElem);
}
}
}