IDEMPIERE-3863 Import/Export translation issue with java 11

This commit is contained in:
Carlos Ruiz 2019-01-09 16:04:14 +01:00
parent b69462198f
commit 949c2b02cf
2 changed files with 16 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParser;
@ -204,7 +205,7 @@ public class Translation implements IApplication
// System.out.println(factory.getClass().getName());
DocumentBuilder builder = factory.newDocumentBuilder();
// <!DOCTYPE idempiereTrl SYSTEM "http://www.idempiere.org/dtd/idempiereTrl.dtd">
// <!DOCTYPE idempiereTrl PUBLIC "-//ComPiere, Inc.//DTD iDempiere Translation 1.0//EN" "http://www.idempiere.org/dtd/idempiereTrl.dtd">
// <!DOCTYPE idempiereTrl PUBLIC "-//ComPiere, Inc.//DTD iDempiere Translation 1.0//EN" "http://www.idempiere.com/dtd/idempiereTrl.dtd">
Document document = builder.newDocument();
document.appendChild(document.createComment(Adempiere.getSummaryAscii()));
document.appendChild(document.createComment(DTD));
@ -277,6 +278,7 @@ public class Translation implements IApplication
valueString = "";
value.setAttribute(XML_VALUE_ATTRIBUTE_ORIGINAL, origString);
if (valueString.indexOf("<") != -1 || valueString.indexOf(">") != -1 || valueString.indexOf("&") != -1) {
value.setAttributeNS(XMLConstants.XML_NS_URI, "space", "preserve");
value.appendChild(document.createCDATASection(valueString));
} else {
value.appendChild(document.createTextNode(valueString));

View File

@ -38,6 +38,7 @@ import java.util.Properties;
import java.util.UUID;
import java.util.logging.Level;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
@ -4577,7 +4578,10 @@ public abstract class PO
if (value == null || value.equals (Null.NULL))
;
else if (c == Object.class)
{
col.setAttributeNS(XMLConstants.XML_NS_URI, "space", "preserve");
col.appendChild(document.createCDATASection(value.toString()));
}
else if (value instanceof Integer || value instanceof BigDecimal)
col.appendChild(document.createTextNode(value.toString()));
else if (c == Boolean.class)
@ -4592,11 +4596,20 @@ public abstract class PO
else if (value instanceof Timestamp)
col.appendChild(document.createTextNode(value.toString()));
else if (c == String.class)
{
col.setAttributeNS(XMLConstants.XML_NS_URI, "space", "preserve");
col.appendChild(document.createCDATASection((String)value));
}
else if (DisplayType.isLOB(dt))
{
col.setAttributeNS(XMLConstants.XML_NS_URI, "space", "preserve");
col.appendChild(document.createCDATASection(value.toString()));
}
else
{
col.setAttributeNS(XMLConstants.XML_NS_URI, "space", "preserve");
col.appendChild(document.createCDATASection(value.toString()));
}
//
root.appendChild(col);
}