Skip to content

Commit

Permalink
Extract MANIFEST namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
tan9 committed Sep 13, 2023
1 parent 0afd47f commit 9307e9f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/com/github/miachm/sods/OdsWritter.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,32 @@ private void writeManifest() {
XMLStreamWriter out = XMLOutputFactory.newInstance().createXMLStreamWriter(
new OutputStreamWriter(output, "utf-8"));

final String namespace = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";

out.writeStartDocument("UTF-8", "1.0");
out.writeStartElement("manifest:manifest");
out.writeNamespace("manifest", namespace);
out.writeAttribute(namespace, "version", "1.2");

out.writeStartElement(namespace, "file-entry");
out.writeAttribute(namespace, "full-path", "/");
out.writeAttribute(namespace, "version", "1.2");
out.writeAttribute(namespace, "media-type", MIMETYPE);
out.setPrefix("manifest", MANIFEST);
out.writeStartElement(MANIFEST, "manifest");
out.writeNamespace("manifest", MANIFEST);
out.writeAttribute(MANIFEST, "version", "1.2");

out.writeStartElement(MANIFEST, "file-entry");
out.writeAttribute(MANIFEST, "full-path", "/");
out.writeAttribute(MANIFEST, "version", "1.2");
out.writeAttribute(MANIFEST, "media-type", MIMETYPE);
out.writeEndElement();

out.writeStartElement(namespace, "file-entry");
out.writeAttribute(namespace, "full-path", "content.xml");
out.writeAttribute(namespace, "media-type", "text/xml");
out.writeStartElement(MANIFEST, "file-entry");
out.writeAttribute(MANIFEST, "full-path", "content.xml");
out.writeAttribute(MANIFEST, "media-type", "text/xml");
out.writeEndElement();

out.writeStartElement(namespace, "file-entry");
out.writeAttribute(namespace, "full-path", "styles.xml");
out.writeAttribute(namespace, "media-type", "text/xml");
out.writeStartElement(MANIFEST, "file-entry");
out.writeAttribute(MANIFEST, "full-path", "styles.xml");
out.writeAttribute(MANIFEST, "media-type", "text/xml");
out.writeEndElement();

for (FileEntry entry : spread.getExtraFiles()) {
out.writeStartElement(namespace, "file-entry");
out.writeAttribute(namespace, "full-path", entry.path);
out.writeAttribute(namespace, "media-type", entry.mimetype);
out.writeStartElement(MANIFEST, "file-entry");
out.writeAttribute(MANIFEST, "full-path", entry.path);
out.writeAttribute(MANIFEST, "media-type", entry.mimetype);
out.writeEndElement();
}

Expand Down
1 change: 1 addition & 0 deletions src/com/github/miachm/sods/OpenDocumentNamespaces.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.miachm.sods;

public class OpenDocumentNamespaces {
final static String MANIFEST = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
final static String OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
final static String TABLE = "urn:oasis:names:tc:opendocument:xmlns:table:1.0";
final static String TEXT = "urn:oasis:names:tc:opendocument:xmlns:text:1.0";
Expand Down

0 comments on commit 9307e9f

Please sign in to comment.