/** * Serializes the xml document to the writer. * * @throws DOMSerializerException if error occurs. */ public void serialize(final Document document, final Writer out) throws DOMSerializerException { serialize((Node) document, out); }
/** * Serializes the document to the output stream. * * @throws DOMSerializerException if error occurs. */ public void serialize(final Document document, final OutputStream out) throws DOMSerializerException { serialize((Node) document, out); }
/** * Converts the node to a String. * * @throws DOMSerializerException if error occurs. */ public String serializeToString(final Node node) throws DOMSerializerException { StringWriter writer = new StringWriter(); serialize(node, writer); return writer.toString(); }
/** * Converts the node to a byte[]. * * @throws DOMSerializerException if error occurs. */ public byte[] serializeToBytes(final Node node) throws DOMSerializerException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); serialize(node, bout); return bout.toByteArray(); }
public void writeTo(OutputStream os) { DOMSerializer.createNew().serialize(m_capsDoc, os); }
@Override public void write(String charset, Map<String, Iterable<String>> header, OutputStream outstream) throws IOException { DOMSerializer serializer = DOMSerializer.createNew(DOMSerializerOptions.getDefaultOptions().encoding(charset)); serializer.serialize(m_xmlContent, outstream); }
public void handleChunkEnd(final List<QName> currentXPath, final QName handlerQName, final String xmlChunk) { Element request = DOMParser.createNew().parse(new InputSource(new StringReader(xmlChunk))).getDocumentElement(); if (LOG.isDebugEnabled()) { debugPDPRequest(request); } Element response = getDecisionService().evaluate(request); if (request.isDefaultNamespace(PDP_REQUEST_NAME_V2.getNamespaceURI())) { response.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, PDP_REQUEST_NAME_V2.getNamespaceURI()); } if (LOG.isDebugEnabled()) { debugPDPResponse(response); } DOMSerializer.createNew(DOMSerializerOptions.getDefaultOptions().omitXMLDeclaration().encodingUTF8()) .serialize(response, out); }
public ResponseDocument executeRequest(RequestDocument request) throws DecisionProcessingException { Document responseDoc; try { responseDoc = getDecisionServiceAdapter().evaluate((Document) request.getDomNode()); // The commented version is 50 per cent faster but fails with Xalan, // so we convert everything into byte[] :( ByteArrayOutputStream outStream = new ByteArrayOutputStream(); DOMSerializer.createNew().serialize(responseDoc, outStream); //return ResponseDocument.Factory.parse(responseDoc); return ResponseDocument.Factory.parse(new ByteArrayInputStream(outStream.toByteArray())); } catch (Exception e) { throw new DecisionProcessingException("Could not evaluate PolicyRequest.", e); } }