diff --git a/src/main/java/w2phtml/project.properties b/src/main/java/w2phtml/project.properties index 0ad234b..57183de 100644 --- a/src/main/java/w2phtml/project.properties +++ b/src/main/java/w2phtml/project.properties @@ -1,3 +1,3 @@ -#Wed Apr 22 15:32:34 CEST 2020 +#Wed Apr 22 20:17:51 CEST 2020 releaseVersion=0.5.7 -releaseDate=15\:32\:34 22-04-2020 +releaseDate=20\:17\:51 22-04-2020 diff --git a/src/main/java/w2phtml/rdf/DocumentPart.java b/src/main/java/w2phtml/rdf/DocumentPart.java index 6890a6d..46ec8dd 100644 --- a/src/main/java/w2phtml/rdf/DocumentPart.java +++ b/src/main/java/w2phtml/rdf/DocumentPart.java @@ -2,6 +2,7 @@ package w2phtml.rdf; import java.io.StringWriter; import java.util.HashMap; +import java.util.HashSet; import java.util.Set; import javax.xml.transform.OutputKeys; @@ -15,11 +16,13 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; +import w2phtml.util.Misc; import w2phtml.xhtml.XhtmlDocument; public class DocumentPart { @@ -41,8 +44,40 @@ public class DocumentPart { extractNumber(); extractBody(); calculateParentPath(); + extractAnnotationMetadata(); + } + private void extractAnnotationMetadata() { + metadata = new HashMap>(); + if (excerptDoc == null) { + System.out.println("Error. Excerpt doc is null!"); + return; + } + Element head = excerptDoc.getHeadNode(); + if (head == null) { + System.out.println("Error. Head node is null!"); + return; + } + NodeList metas = head.getElementsByTagName("meta"); + for (int i = 0; i < metas.getLength();i++) { + Node meta = metas.item(i); + if (Misc.isElement(meta)) { + Element metaElements = (Element) meta; + if (metaElements.hasAttribute("name") && metaElements.hasAttribute("content")) { + String metaName = metaElements.getAttribute("name"); + String metaValue = metaElements.getAttribute("content"); + if (metadata.containsKey(metaName)) { + metadata.get(metaName).add(metaValue); + } else { + Set names = new HashSet(); + names.add(metaValue); + metadata.put(metaName, names); + } + } + } + } } public DocumentPart(String path) { + metadata = new HashMap>(); this.path = path; this.name = ""; extractNumber(); @@ -103,11 +138,7 @@ public class DocumentPart { this.metadata = metadata; } public HashMap> getMetadata(){ - if (metadata == null) { - return new HashMap>(); - } else { - return metadata; - } + return metadata; } private void extractPath() { diff --git a/src/main/java/w2phtml/rdf/DocumentStructure.java b/src/main/java/w2phtml/rdf/DocumentStructure.java index 8484855..48f959e 100644 --- a/src/main/java/w2phtml/rdf/DocumentStructure.java +++ b/src/main/java/w2phtml/rdf/DocumentStructure.java @@ -194,7 +194,7 @@ public class DocumentStructure { } } System.out.println(resource.getNameSpace() + " " + name); - System.out.println("rightNamespace" + TS + EXCERPT ); + System.out.println("rightNamespace " + TS + EXCERPT ); return false; } private String convertName(String name) { diff --git a/src/main/java/w2phtml/xhtml/Converter.java b/src/main/java/w2phtml/xhtml/Converter.java index 98ed9ff..a2a7d61 100644 --- a/src/main/java/w2phtml/xhtml/Converter.java +++ b/src/main/java/w2phtml/xhtml/Converter.java @@ -252,7 +252,9 @@ public class Converter extends BasicConverter { public L10n getL10n() { return l10n; } - public void setOpenPubStructure(boolean b) { isEPUB = true; } + public void setOpenPubStructure(boolean b) { + isEPUB = b; + } public boolean isOPS() { return isEPUB; } diff --git a/src/main/java/w2phtml/xhtml/content/Separator.java b/src/main/java/w2phtml/xhtml/content/Separator.java index af7826a..66e6586 100644 --- a/src/main/java/w2phtml/xhtml/content/Separator.java +++ b/src/main/java/w2phtml/xhtml/content/Separator.java @@ -417,6 +417,9 @@ public class Separator { } public void appendMetadata(String name, String value) { + if (!greenstoneSeparation) { + return; + } if (currentComment == null) { System.out.println("Error. No current Comment"); return;