MarkLogicPatchItemWriter implements ItemWriter<String[]> { @Override public void write(List<? extends String[]> items) throws Exception { for (String[] item : items) { String uri = item[0]; String xmlPatch = item[1]; logger.info(uri); XMLDocumentManager docMgr = databaseClient.newXMLDocumentManager(); EditableNamespaceContext namespaces = new EditableNamespaceContext(); namespaces.put("html", "http: DocumentPatchBuilder xmlPatchBldr = docMgr.newPatchBuilder(); xmlPatchBldr.setNamespaces(namespaces); DocumentPatchHandle patchHandle = xmlPatchBldr.insertFragment("/doc", DocumentPatchBuilder.Position.LAST_CHILD, xmlPatch).build(); docMgr.patch(uri, patchHandle); } } MarkLogicPatchItemWriter(DatabaseClient client); @Override void write(List<? extends String[]> items);  }
@Test public void patchItemWriterTest() throws Exception { MarkLogicPatchItemWriter itemWriter = new MarkLogicPatchItemWriter(client); String[] info = new String[2]; info[0] = "hello.xml"; info[1] = "<new>content</new>"; List<String[]> strings = new ArrayList<String[]>(); strings.add(info); itemWriter.write(strings); StringHandle handle = docMgr.read("hello.xml", new StringHandle()); logger.info(handle.toString()); Fragment frag = new Fragment(handle.toString()); frag.assertElementExists("Expecting new content", " }