cleanup for r1812475: avoid NPEs from string.isEmpty()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812520 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2017-10-18 14:29:56 +00:00
parent fc2bcfae9a
commit 42c4e4909c

View File

@ -163,7 +163,8 @@ public class XSSFExportToXml implements Comparator<String>{
mapCellOnNode(cell,currentNode);
//remove nodes which are empty in order to keep the output xml valid
if (currentNode.getTextContent().isEmpty() && currentNode.getParentNode() != null) {
// FIXME: what should be done if currentNode.getTextContent() is null?
if ("".equals(currentNode.getTextContent()) && currentNode.getParentNode() != null) {
currentNode.getParentNode().removeChild(currentNode);
}
}
@ -467,7 +468,8 @@ public class XSSFExportToXml implements Comparator<String>{
// Note: we expect that all the complex types are defined at root level
Node complexTypeNode = null;
if (!complexTypeName.isEmpty()) {
// FIXME: what should be done if complexTypeName is null?
if (!"".equals(complexTypeName)) {
complexTypeNode = getComplexTypeNodeFromSchemaChildren(xmlSchema, null, complexTypeName);
}
@ -483,8 +485,7 @@ public class XSSFExportToXml implements Comparator<String>{
NodeList list = localComplexTypeRootNode.getChildNodes();
String complexTypeName = "";
for(int i=0; i< list.getLength();i++) {
Node node = list.item(i);
for(final Node node : list) {
if ( node instanceof Element && "element".equals(node.getLocalName())) {
Node nameAttribute = getNameOrRefElement(node);
if (nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) {