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

View File

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