Package com.sun.xml.fastinfoset.stax

Examples of com.sun.xml.fastinfoset.stax.StAXDocumentSerializer


    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());
View Full Code Here


    //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();
      if (preserve) {
        element.serialize(streamWriter);
      } else {
        element.serializeAndConsume(streamWriter);
      }
      streamWriter.writeEndDocument();
    } catch (XMLStreamException xmlse) {
      logger.error(xmlse.getMessage());
      throw new AxisFault(xmlse.getMessage(), xmlse);
    }
  }
View Full Code Here

    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());
View Full Code Here

      OutputStream outputStream, boolean preserve) throws AxisFault {
        OMElement element = messageContext.getEnvelope();
   
    try {
      //Create the StAX document serializer
      XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream);
      if (preserve) {
        element.serialize(streamWriter);
      } else {
        element.serializeAndConsume(streamWriter);
      }
//      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);
    }
  }
View Full Code Here

     *        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;
    }
View Full Code Here

        try {
            // first let's read the xml document in to Axiom
            OMElement element = new StAXOMBuilder(inputFile).getDocumentElement();

            // output it using binary xml outputter
            XMLStreamWriter streamWriter = new StAXDocumentSerializer(new FileOutputStream(tempFile));
            streamWriter.writeStartDocument();
            element.serializeAndConsume(streamWriter);
            streamWriter.writeEndDocument();

            // now let's read the binary file in to Axiom
            XMLStreamReader streamReader = new StAXDocumentParser(new FileInputStream(tempFile));
            StAXBuilder builder = new StAXOMBuilder(streamReader);
            builder.getDocumentElement().serialize(new FileWriter(outputFile));
View Full Code Here

    }
   
    protected final void writeTo(JAXBElement<?> t, MediaType mediaType, Charset c,
            Marshaller m, OutputStream entityStream)
            throws JAXBException, IOException {       
        final XMLStreamWriter xsw = new StAXDocumentSerializer(entityStream);
        m.marshal(t, xsw);
        try {
            xsw.flush();
        } catch (XMLStreamException cause) {
            throw ThrowHelper.withInitCause(cause,
                    new IOException()
                    );           
        }
View Full Code Here

   
    public final void writeList(Class<?> elementType, Collection<?> t,
            MediaType mediaType, Charset c,
            Marshaller m, OutputStream entityStream)
            throws JAXBException, IOException {
        final XMLStreamWriter xsw = new StAXDocumentSerializer(entityStream);
       
        final String rootElement = getRootElementName(elementType);
       
        try {
            xsw.writeStartDocument();
            xsw.writeStartElement(rootElement);
            for (Object o : t)
                m.marshal(o, xsw);
            xsw.writeEndElement();
            xsw.writeEndDocument();
            xsw.flush();
        } catch (XMLStreamException cause) {
            throw ThrowHelper.withInitCause(cause,
                    new IOException()
                    );           
        }
View Full Code Here

   
    @Override
    protected void writeTo(Object t, MediaType mediaType, Charset c,
            Marshaller m, OutputStream entityStream)
            throws JAXBException, IOException {
        XMLStreamWriter xsw = new StAXDocumentSerializer(entityStream);
        m.marshal(t, xsw);
        try {
            xsw.flush();
        } catch (XMLStreamException cause) {
            throw ThrowHelper.withInitCause(cause,
                    new IOException()
                    );
        }
View Full Code Here


   protected static XMLStreamWriter getFastinfoSetXMLStreamWriter(OutputStream entityStream)
   {
      BufferedOutputStream out = new BufferedOutputStream(entityStream, 2048);
      XMLStreamWriter writer = new StAXDocumentSerializer(out);
      return writer;
   }
View Full Code Here

TOP

Related Classes of com.sun.xml.fastinfoset.stax.StAXDocumentSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.