From: Dominik Stadler Date: Sun, 8 Dec 2013 08:39:10 +0000 (+0000) Subject: Refactor XSSFExportToXml a bit, split code into more methods X-Git-Tag: REL_3_10_FINAL~37 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2fdc436d8e67fb92984c18724f15e8f78630863c;p=poi.git Refactor XSSFExportToXml a bit, split code into more methods git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1549008 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java index a6e1a2785a..80b0c34deb 100644 --- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java +++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java @@ -447,15 +447,23 @@ public class XSSFExportToXml implements Comparator{ } private Node getComplexTypeForElement(String elementName,Node xmlSchema,Node localComplexTypeRootNode) { - Node complexTypeNode = null; - String elementNameWithoutNamespace = removeNamespace(elementName); + String complexTypeName = getComplexTypeNameFromChildren(localComplexTypeRootNode, elementNameWithoutNamespace); - NodeList list = localComplexTypeRootNode.getChildNodes(); - String complexTypeName = ""; + // Note: we expect that all the complex types are defined at root level + Node complexTypeNode = null; + if (!"".equals(complexTypeName)) { + complexTypeNode = getComplexTypeNodeFromSchemaChildren(xmlSchema, complexTypeNode, complexTypeName); + } + return complexTypeNode; + } + private String getComplexTypeNameFromChildren(Node localComplexTypeRootNode, + String elementNameWithoutNamespace) { + NodeList list = localComplexTypeRootNode.getChildNodes(); + String complexTypeName = ""; for(int i=0; i< list.getLength();i++) { Node node = list.item(i); @@ -472,32 +480,34 @@ public class XSSFExportToXml implements Comparator{ } } } - // Note: we expect that all the complex types are defined at root level - if (!"".equals(complexTypeName)) { - NodeList complexTypeList = xmlSchema.getChildNodes(); - for(int i=0; i< complexTypeList.getLength();i++) { - Node node = complexTypeList.item(i); - if ( node instanceof Element) { - if (node.getLocalName().equals("complexType")) { - Node nameAttribute = node.getAttributes().getNamedItem("name"); - if (nameAttribute.getNodeValue().equals(complexTypeName)) { - - NodeList complexTypeChildList =node.getChildNodes(); - for(int j=0; j