diff --git a/src/main/java/writer2latex/xhtml/content/Separator.java b/src/main/java/writer2latex/xhtml/content/Separator.java index e91adb8..68d0e6a 100644 --- a/src/main/java/writer2latex/xhtml/content/Separator.java +++ b/src/main/java/writer2latex/xhtml/content/Separator.java @@ -47,6 +47,7 @@ public class Separator { alignSplitToPages = config.getAlignSplitsToPages(); breakStyle = config.getPageBreakStyle(); pageContainer = converter.pageContainer; + rdfSeparation = converter.isRDF; headingPath = new int[10]; } @@ -55,10 +56,10 @@ public class Separator { // Get outline level String sLevel = getAttribute(currentNode, XMLString.TEXT_OUTLINE_LEVEL); // System.out.println(sLevel); - String title = getTitle(currentNode).trim(); if (sLevel == null || sLevel.isEmpty()) { return hnode; } + String title = getTitle(currentNode).trim(); if (title == null || title.isEmpty()) { return hnode; } @@ -273,30 +274,36 @@ public class Separator { public static String getTitle(Node currentNode) { Node content = currentNode.cloneNode(true); - NodeList contentNodes = content.getChildNodes(); String title = null; + NodeList lineBreaks = ((Element) content).getElementsByTagName(XMLString.TEXT_LINE_BREAK); + NodeList textTabs = ((Element) content).getElementsByTagName(XMLString.TEXT_TAB); - int i = 0; - while (i < contentNodes.getLength()) { - Node child = contentNodes.item(i); - if (isElement(child)) { - if (child.getNodeName().equals(XMLString.TEXT_TAB) || child.getNodeName().equals(XMLString.TEXT_LINE_BREAK)) { - Document doc = child.getOwnerDocument(); - Node testSpace = doc.createTextNode(" "); - content.insertBefore(testSpace, child); - content.removeChild(child); - } - } - i++; - } + replaceWithSpaces(lineBreaks); + replaceWithSpaces(textTabs); + deleteNotesIn(content); + title = content.getTextContent(); + return title; + } + + private static void deleteNotesIn(Node content) { NodeList notes = ((Element) content).getElementsByTagName(XMLString.TEXT_NOTE); int j = 0; while (j < notes.getLength()) { Node note = notes.item(j); note.getParentNode().removeChild(note); } - title = content.getTextContent(); - return title; + } + + private static void replaceWithSpaces(NodeList contentNodes) { + int i = 0; + while (i < contentNodes.getLength()) { + Node node = contentNodes.item(i); + Document doc = node.getOwnerDocument(); + Node testSpace = doc.createTextNode(" "); + node.getParentNode().insertBefore(testSpace, node); + node.getParentNode().removeChild(node); + i++; + } } private static void openCommentHeading(Node hnode, String title) {