WhitespaceProcessor { public String getText(Node element) { String result = ""; int spaceCount; Node node = element.getFirstChild(); while (node != null) { if (node.getNodeType() == Node.TEXT_NODE) { result += node.getNodeValue(); } else if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getLocalName().equals("s")) { try { spaceCount = Integer.parseInt(((Element) node).getAttributeNS(OdfDocumentNamespace.TEXT .getUri(), "c")); } catch (Exception e) { spaceCount = 1; } for (int i = 0; i < spaceCount; i++) { result += " "; } } else if (node.getLocalName().equals("line-break")) { result += "\n"; } else if (node.getLocalName().equals("tab")) { result += "\t"; } else { result = result + getText(node); } } node = node.getNextSibling(); } return result; }  void append(Element element, String content); String getText(Node element); static void appendText(Element element, String content);  }
@Test public void testGetText() { LOG.info("getText"); Node element = null; WhitespaceProcessor instance = new WhitespaceProcessor(); int i; String expResult = ""; String result; for (i = 0; i < plainText.length; i++) { element = new OdfTextParagraph(dom); constructElement(element, elementResult[i]); result = plainText[i]; expResult = instance.getText(element); Assert.assertEquals(expResult, result); } }