ASiCEWithXAdESManifestBuilder { public Document build() { final Document documentDom = DomUtils.buildDOM(); final Element manifestDom = DomUtils.createElementNS(documentDom, ManifestNamespace.NS, ManifestElement.MANIFEST); DomUtils.setAttributeNS(manifestDom, ManifestNamespace.NS, ManifestAttribute.VERSION, "1.2"); documentDom.appendChild(manifestDom); final Element rootDom = DomUtils.addElement(documentDom, manifestDom, ManifestNamespace.NS, ManifestElement.FILE_ENTRY); DomUtils.setAttributeNS(rootDom, ManifestNamespace.NS, ManifestAttribute.FULL_PATH, "/"); DomUtils.setAttributeNS(rootDom, ManifestNamespace.NS, ManifestAttribute.MEDIA_TYPE, MimeType.ASICE.getMimeTypeString()); for (DSSDocument document : documents) { Element fileDom = DomUtils.addElement(documentDom, manifestDom, ManifestNamespace.NS, ManifestElement.FILE_ENTRY); DomUtils.setAttributeNS(fileDom, ManifestNamespace.NS, ManifestAttribute.FULL_PATH, document.getName()); MimeType mimeType = document.getMimeType(); if (mimeType != null) { DomUtils.setAttributeNS(fileDom, ManifestNamespace.NS, ManifestAttribute.MEDIA_TYPE, mimeType.getMimeTypeString()); } } return documentDom; } ASiCEWithXAdESManifestBuilder(List<DSSDocument> documents); Document build();  }
@Test public void test() { DSSDocument d1 = new InMemoryDocument("hello".getBytes(), "test.txt"); DSSDocument d2 = new InMemoryDocument("world".getBytes(), "test.html"); DSSDocument d3 = new InMemoryDocument("bye".getBytes(), "test.pdf"); List<DSSDocument> documents = Arrays.asList(d1, d2, d3); ASiCEWithXAdESManifestBuilder builder = new ASiCEWithXAdESManifestBuilder(documents); Document doc = builder.build(); String xmlContent = new String(DSSXMLUtils.serializeNode(doc)); LOG.info(xmlContent); assertTrue(xmlContent.contains("xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\"")); assertTrue(xmlContent.contains("manifest:full-path=\"test.txt\"")); assertTrue(xmlContent.contains("manifest:media-type=\"application/vnd.etsi.asic-e+zip\"")); }