From 6c90059fb0480497fa2fcf40db03142cff10e3bd Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Mon, 24 Feb 2020 22:18:35 +0100 Subject: [PATCH] Fixed mistake in previous commit --- .../java/writer2latex/rdf/DocumentPart.java | 3 +- .../writer2latex/rdf/DocumentStructure.java | 30 +++++++++++++------ .../writer2latex/xhtml/content/Separator.java | 3 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/java/writer2latex/rdf/DocumentPart.java b/src/main/java/writer2latex/rdf/DocumentPart.java index ecd8537..cb947a8 100644 --- a/src/main/java/writer2latex/rdf/DocumentPart.java +++ b/src/main/java/writer2latex/rdf/DocumentPart.java @@ -67,8 +67,9 @@ public class DocumentPart { private void calculateParentPath() { if(path.length() == 1) { parentPath = ""; + } else { + parentPath = path.replaceAll(" [0-9]+$", ""); } - parentPath = path.replaceAll(" [0-9]+$", ""); } private void extractBody() { Element excerptContentNode = excerptDoc.getContentNode(); diff --git a/src/main/java/writer2latex/rdf/DocumentStructure.java b/src/main/java/writer2latex/rdf/DocumentStructure.java index 5fef7bc..d6d4af8 100644 --- a/src/main/java/writer2latex/rdf/DocumentStructure.java +++ b/src/main/java/writer2latex/rdf/DocumentStructure.java @@ -22,6 +22,7 @@ public class DocumentStructure { private final String PARSERNAME = "w2phtml"; private final String EXCERPT = "Excerpt"; private final String TOC_ELEMENT = "TOCElement"; + private final String ELENPHARTICLE = "elenphArticle"; private String documentID = "DOC_ID"; Model m; @@ -33,7 +34,6 @@ public class DocumentStructure { } public DocumentStructure(Vector files) { this(); - System.out.println("DocStructure"); Iterator filesIterator = files.iterator(); while (filesIterator.hasNext()) { XhtmlDocument inputDoc = filesIterator.next(); @@ -53,15 +53,12 @@ public class DocumentStructure { if (levels[i].equals("0")) { String emptyPath = createEmptyPath(levels, i); if (!inputParts.containsKey(emptyPath)) { - System.out.println("empty path added " + emptyPath); DocumentPart emptyPart = new DocumentPart(emptyPath); addPart(emptyPart); } } } } - - } private String createEmptyPath(String[] levels, int i) { StringBuilder emptyPath = new StringBuilder(); @@ -93,8 +90,16 @@ public class DocumentStructure { String elementName = TS + TOC_ELEMENT + "/" + PARSERNAME + "_" + documentID + docPart.getSafePath(); Resource element = m.createResource(elementName); elements.put(docPart.getPath(), element); - attachExcerpt(docPart, element); + attachExcerpt(docPart, element); } + + private void createDocumentElement(DocumentPart docPart) { + String elementName = TS + ELENPHARTICLE + "/" + PARSERNAME + "_" + documentID ; + Resource element = m.createResource(elementName); + elements.put(docPart.getPath(), element); + attachExcerpt(docPart, element); + } + private void createTOCItem(DocumentPart docPart) { String tocItemName = TS + TOCITEM + "/" + PARSERNAME + "_" + documentID + docPart.getSafePath(); Resource tocItem = m.createResource(tocItemName); @@ -104,9 +109,10 @@ public class DocumentStructure { tocItem.addLiteral(itemNumber, docPart.getNumber()); tocItem.addProperty(pointsTo, elements.get(docPart.getPath())); - - Resource parent = elements.get(docPart.getParentPath()); - parent.addProperty(hasTOCItem, tocItem); + if (!docPart.getPath().isEmpty()) { + Resource parent = elements.get(docPart.getParentPath()); + m.add(parent, hasTOCItem, tocItem); + } } @@ -137,7 +143,13 @@ public class DocumentStructure { private void createElements() { Set paths = inputParts.keySet(); for (String path : paths) { - createElement(inputParts.get(path)); + DocumentPart part = inputParts.get(path); + if (part.getPath().isEmpty()) { + createDocumentElement(part); + } else { + createElement(part); + } } } + } diff --git a/src/main/java/writer2latex/xhtml/content/Separator.java b/src/main/java/writer2latex/xhtml/content/Separator.java index f8f17d3..d781df9 100644 --- a/src/main/java/writer2latex/xhtml/content/Separator.java +++ b/src/main/java/writer2latex/xhtml/content/Separator.java @@ -70,7 +70,6 @@ public class Separator { if (noSplitNeeded(pageNum, curLevel)) { System.out.println(sLevel + "no split needed"); - return hnode; } @@ -149,7 +148,7 @@ public class Separator { } private boolean isSplitTime(int curLevel, int pageNum) { - if ((rdfSeparation || splitLevel >= curLevel ) && converter.outFileHasContent()) { + if ((rdfSeparation || splitLevel >= curLevel )) { if (alignSplitToPages) { if (lastSplitPageNum != pageNum) { return true;