DocumentFormat xccFormat = null; if (format != null) { if (Format.BINARY.equals(format)) { xccFormat = DocumentFormat.BINARY; } else if (Format.JSON.equals(format)) { xccFormat = DocumentFormat.JSON; } else if (Format.TEXT.equals(format)) { xccFormat = DocumentFormat.TEXT; } else if (Format.XML.equals(format)) { xccFormat = DocumentFormat.XML; } else if (Format.UNKNOWN.equals(format)) { xccFormat = DocumentFormat.NONE; } else if (logger.isDebugEnabled()) {
@Override public String generateOutput(DocumentRecord documentRecord) { if (Format.XML.equals(documentRecord.getFormat())) { DOMHandle handle = documentRecord.getContent(new DOMHandle()); Document document = handle.get(); OutputFormat format = new OutputFormat(handle.get()); format.setOmitXMLDeclaration(omitXmlDeclaration); StringWriter writer = new StringWriter(); try { new XMLSerializer(writer, format).serialize(document); return writer.toString(); } catch (IOException e) { throw new RuntimeException("Unable to serialize XML document to string: " + e.getMessage(), e); } } else if (logger.isDebugEnabled()) { logger.debug(String.format("Document '%s' has a format of '%s', so will not attempt to remove the XML declaration from it", documentRecord.getUri(), documentRecord.getFormat().name())); } return documentRecord.getContent(new StringHandle()).get(); }
for ( DocumentRecord doc : docs ) { Format format = doc.getFormat(); if ( Format.BINARY.equals(format) ) { throw new IllegalStateException("Document " + doc.getUri() + " is binary and cannot be written. Change your query to not select any binary documents.");