Refine search
/** {@inheritDoc} */ @Override protected XMLStreamWriter createStreamWriter(OutputStream output) throws XMLStreamException { return new StAXDocumentSerializer(output); }
public StAXDocumentSerializer(OutputStream outputStream, StAXManager manager) { super(true); setOutputStream(outputStream); _manager = manager; }
public void writeStartDocument() throws XMLStreamException { writeStartDocument("finf", "1.0"); }
/** * Retrieves the raw bytes from the SOAP envelop. * * @see org.apache.axis2.transport.MessageFormatter#getBytes(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat) */ public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault { OMElement element = messageContext.getEnvelope(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { //Creates StAX document serializer which actually implements the XMLStreamWriter XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream); element.serializeAndConsume(streamWriter); //TODO Looks like the SOAP envelop doesn't have an end document tag. Find out why? streamWriter.writeEndDocument(); return outStream.toByteArray(); } catch (XMLStreamException xmlse) { logger.error(xmlse.getMessage()); throw new AxisFault(xmlse.getMessage(), xmlse); } }
/** * Create a new (@link StAXDocumentSerializer} instance. * * @param in the OutputStream to serialize to. * @param retainState if true the serializer should retain the state of * vocabulary tables for multiple serializations. * @return a new {@link StAXDocumentSerializer} instance. */ /* package */ static StAXDocumentSerializer createNewStreamWriter(OutputStream out, boolean retainState, int indexedStringSizeLimit, int stringsMemoryLimit) { StAXDocumentSerializer serializer = new StAXDocumentSerializer(out); if (retainState) { /** * Create a serializer vocabulary external to the serializer. * This will ensure that the vocabulary will never be cleared * for each serialization and will be retained (and will grow) * for each serialization */ SerializerVocabulary vocabulary = new SerializerVocabulary(); serializer.setVocabulary(vocabulary); serializer.setMinAttributeValueSize(0); serializer.setMaxAttributeValueSize(indexedStringSizeLimit); serializer.setMinCharacterContentChunkSize(0); serializer.setMaxCharacterContentChunkSize(indexedStringSizeLimit); serializer.setAttributeValueMapMemoryLimit(stringsMemoryLimit); serializer.setCharacterContentChunkMapMemoryLimit(stringsMemoryLimit); } return serializer; }
private XMLStreamWriter getXMLWriter( OutputStream os ) throws XMLStreamException, IOException { XMLStreamWriter writer = null; switch ( compression ) { case FAST_INFOSET: { StAXDocumentSerializer staxDocumentSerializer = new StAXDocumentSerializer(); staxDocumentSerializer.setOutputStream( os ); writer = staxDocumentSerializer; break; } case GZIP: { GZIPOutputStream gos = new GZIPOutputStream( os ); writer = xmlOutputFactory.createXMLStreamWriter( gos, "UTF-8" ); writer = new XMLStreamWriterWrapper( writer, gos ); break; } case NONE: { writer = xmlOutputFactory.createXMLStreamWriter( os, "UTF-8" ); break; } } return writer; }
/** * Creates a new {@link StAXDocumentSerializer} (Fast Infoset {@link XMLStreamWriter}) instance. * * @param os * binary stream to write to, must not be <code>null</code> * @param voc * vocabulary to use, must not be <code>null</code> * @param vocUri * uri used for declaring the external vocabulary, must not be <code>null</code> or empty * @return binary XML writer, never <code>null</code> */ public static StAXDocumentSerializer getFIWriter( OutputStream os, SerializerVocabulary voc, String vocUri ) { SerializerVocabulary sVoc = new SerializerVocabulary(); voc.setExternalVocabulary( vocUri, sVoc, false ); StAXDocumentSerializer writer = new StAXDocumentSerializer(); writer.setVocabulary( voc ); writer.setOutputStream( os ); return writer; }
public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream, String encoding) throws XMLStreamException { StAXDocumentSerializer serializer = new StAXDocumentSerializer(outputStream, new StAXManager(_manager)); serializer.setEncoding(encoding); return serializer; }
/** * Write the SOAP envelop to the given OutputStream. * * @see org.apache.axis2.transport.MessageFormatter#writeTo(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.io.OutputStream, boolean) */ public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { OMElement element = messageContext.getEnvelope(); try { //Create the StAX document serializer XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream); streamWriter.writeStartDocument(); element.serialize(streamWriter, preserve); // TODO Looks like the SOAP envelop doesn't have a end document tag. Find out why? streamWriter.writeEndDocument(); } catch (XMLStreamException xmlse) { logger.error(xmlse.getMessage()); throw new AxisFault(xmlse.getMessage(), xmlse); } }
/** * Create a new (@link StAXDocumentSerializer} instance. * * @param in the OutputStream to serialize to. * @param retainState if true the serializer should retain the state of * vocabulary tables for multiple serializations. * @return a new {@link StAXDocumentSerializer} instance. */ /* package */ static StAXDocumentSerializer createNewStreamWriter(OutputStream out, boolean retainState, int indexedStringSizeLimit, int stringsMemoryLimit) { StAXDocumentSerializer serializer = new StAXDocumentSerializer(out); if (retainState) { /** * Create a serializer vocabulary external to the serializer. * This will ensure that the vocabulary will never be cleared * for each serialization and will be retained (and will grow) * for each serialization */ SerializerVocabulary vocabulary = new SerializerVocabulary(); serializer.setVocabulary(vocabulary); serializer.setMinAttributeValueSize(0); serializer.setMaxAttributeValueSize(indexedStringSizeLimit); serializer.setMinCharacterContentChunkSize(0); serializer.setMaxCharacterContentChunkSize(indexedStringSizeLimit); serializer.setAttributeValueMapMemoryLimit(stringsMemoryLimit); serializer.setCharacterContentChunkMapMemoryLimit(stringsMemoryLimit); } return serializer; }
public void parse(InputStream xml, OutputStream finf, String workingDirectory) throws Exception { StAXDocumentSerializer documentSerializer = new StAXDocumentSerializer(); documentSerializer.setOutputStream(finf); SAX2StAXWriter saxTostax = new SAX2StAXWriter(documentSerializer); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); saxParserFactory.setNamespaceAware(true); SAXParser saxParser = saxParserFactory.newSAXParser(); XMLReader reader = saxParser.getXMLReader(); reader.setProperty("http://xml.org/sax/properties/lexical-handler", saxTostax); reader.setContentHandler(saxTostax); if (workingDirectory != null) { reader.setEntityResolver(createRelativePathResolver(workingDirectory)); } reader.parse(new InputSource(xml)); xml.close(); finf.close(); }
public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream, String encoding) throws XMLStreamException { StAXDocumentSerializer serializer = new StAXDocumentSerializer(outputStream, new StAXManager(_manager)); serializer.setEncoding(encoding); return serializer; }
/** * Retrieves the raw bytes from the SOAP envelop. * * @see org.apache.axis2.transport.MessageFormatter#getBytes(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat) */ public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault { //For POX drop the SOAP envelope and use the message body OMElement element = messageContext.getEnvelope().getBody().getFirstElement(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { //Creates StAX document serializer which actually implements the XMLStreamWriter XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream); //Since we drop the SOAP envelop we have to manually write the start document and the end document events streamWriter.writeStartDocument(); element.serializeAndConsume(streamWriter); streamWriter.writeEndDocument(); return outStream.toByteArray(); } catch (XMLStreamException xmlse) { logger.error(xmlse.getMessage()); throw new AxisFault(xmlse.getMessage(), xmlse); } }
/** * Create a new (@link StAXDocumentSerializer} instance. * * @param in the OutputStream to serialize to. * @param retainState if true the serializer should retain the state of * vocabulary tables for multiple serializations. * @return a new {@link StAXDocumentSerializer} instance. */ /* package */ static StAXDocumentSerializer createNewStreamWriter(OutputStream out, boolean retainState, int indexedStringSizeLimit, int stringsMemoryLimit) { StAXDocumentSerializer serializer = new StAXDocumentSerializer(out); if (retainState) { /** * Create a serializer vocabulary external to the serializer. * This will ensure that the vocabulary will never be cleared * for each serialization and will be retained (and will grow) * for each serialization */ SerializerVocabulary vocabulary = new SerializerVocabulary(); serializer.setVocabulary(vocabulary); serializer.setMinAttributeValueSize(0); serializer.setMaxAttributeValueSize(indexedStringSizeLimit); serializer.setMinCharacterContentChunkSize(0); serializer.setMaxCharacterContentChunkSize(indexedStringSizeLimit); serializer.setAttributeValueMapMemoryLimit(stringsMemoryLimit); serializer.setCharacterContentChunkMapMemoryLimit(stringsMemoryLimit); } return serializer; }
protected static XMLStreamWriter getFastinfoSetXMLStreamWriter(OutputStream entityStream) { BufferedOutputStream out = new BufferedOutputStream(entityStream, 2048); XMLStreamWriter writer = new StAXDocumentSerializer(out); return writer; }
public void parse(InputStream xml, OutputStream finf, String workingDirectory) throws Exception { StAXDocumentSerializer documentSerializer = new StAXDocumentSerializer(); documentSerializer.setOutputStream(finf); SAX2StAXWriter saxTostax = new SAX2StAXWriter(documentSerializer); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); saxParserFactory.setNamespaceAware(true); SAXParser saxParser = saxParserFactory.newSAXParser(); XMLReader reader = saxParser.getXMLReader(); reader.setProperty("http://xml.org/sax/properties/lexical-handler", saxTostax); reader.setContentHandler(saxTostax); if (workingDirectory != null) { reader.setEntityResolver(createRelativePathResolver(workingDirectory)); } reader.parse(new InputSource(xml)); xml.close(); finf.close(); }
public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream, String encoding) throws XMLStreamException { StAXDocumentSerializer serializer = new StAXDocumentSerializer(outputStream, new StAXManager(_manager)); serializer.setEncoding(encoding); return serializer; }
public StAXDocumentSerializer(OutputStream outputStream, StAXManager manager) { super(true); setOutputStream(outputStream); _manager = manager; }
public void writeStartDocument() throws XMLStreamException { writeStartDocument("finf", "1.0"); }
/** * Write the SOAP envelop to the given OutputStream. * * @see org.apache.axis2.transport.MessageFormatter#writeTo(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.io.OutputStream, boolean) */ public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { //For POX drop the SOAP envelope and use the message body OMElement element = messageContext.getEnvelope().getBody().getFirstElement(); try { //Create the StAX document serializer XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream); //Since we drop the SOAP envelop we have to manually write the start document and the end document events streamWriter.writeStartDocument(); element.serialize(streamWriter, preserve); streamWriter.writeEndDocument(); } catch (XMLStreamException xmlse) { logger.error(xmlse.getMessage()); throw new AxisFault(xmlse.getMessage(), xmlse); } }