Package javax.xml.stream

Examples of javax.xml.stream.XMLOutputFactory


     *
     * @throws IOException if there are problems writing to the file.
     */
    public void write(MappingDocument doc, PrintWriter stream) throws IOException {
        try {
          XMLOutputFactory xof = XMLOutputFactory.newInstance();
          writer = xof.createXMLStreamWriter(stream);
          writer.writeStartDocument("UTF-8", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
          writer.writeStartElement(ELEM_ROOT);
          writeElement(MappingNodeConstants.Tags.DOCUMENT_ENCODING, doc.getDocumentEncoding());
          writeElement(MappingNodeConstants.Tags.FORMATTED_DOCUMENT, Boolean.toString(doc.isFormatted()));
          loadNode(doc.getRootNode());
View Full Code Here


     
      @Override
      public void translate(Writer writer) throws TransformerException,
          IOException {
        try {
          XMLOutputFactory factory = getOutputFactory();
          XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
          XMLEventFactory eventFactory = XMLEventFactory.newInstance();
          for (Evaluator.NameValuePair nameValuePair : values) {
            if (nameValuePair.value == null) {
              continue;
            }
View Full Code Here

     
      @Override
      public void translate(Writer writer) throws TransformerException,
          IOException {
        try {
          XMLOutputFactory factory = getOutputFactory();
          XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
          XMLEventFactory eventFactory = XMLEventFactory.newInstance();
          addElement(name, writer, eventWriter, eventFactory, namespaces, attributes, contents);
          eventWriter.close();
        } catch (XMLStreamException e) {
          throw new TransformerException(e);
View Full Code Here

    }
   
  }
 
  private static XMLOutputFactory getOutputFactory() throws FactoryConfigurationError {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    if (factory.isPropertySupported(P_OUTPUT_VALIDATE_STRUCTURE)) {
      factory.setProperty(P_OUTPUT_VALIDATE_STRUCTURE, false);
    }
    return factory;
  }
View Full Code Here

      @Override
      public void translate(Writer writer) throws TransformerException,
          IOException {
          try {
            JSONParser parser = new JSONParser();
          XMLOutputFactory factory = getOutputFactory();
          final XMLStreamWriter streamWriter = factory.createXMLStreamWriter(writer);
           
          parser.parse(r, new JsonToXmlContentHandler(escapeName(rootName, true), streamWriter));
           
          streamWriter.flush(); //woodstox needs a flush rather than a close
        } catch (XMLStreamException e) {
View Full Code Here

       
        // marshal root object back out to document in memory
        IMarshallingContext mctx = bfact.createMarshallingContext();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            XMLOutputFactory ofact = XMLOutputFactory.newInstance();
            XMLStreamWriter wrtr = ofact.createXMLStreamWriter(bos, enc);
            mctx.setXmlWriter(new StAXWriter(bfact.getNamespaces(), wrtr));
            mctx.marshalDocument(obj);
        } catch (XMLStreamException e) {
            throw new JiBXException("Error creating writer", e);
        }
View Full Code Here

       
        // marshal root object back out to document in memory
        IMarshallingContext mctx = bfact.createMarshallingContext();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            XMLOutputFactory ofact = XMLOutputFactory.newInstance();
            XMLStreamWriter wrtr = ofact.createXMLStreamWriter(bos, enc);
            mctx.setXmlWriter(new StAXWriter(bfact.getNamespaces(), wrtr));
            mctx.marshalDocument(obj);
        } catch (XMLStreamException e) {
            throw new JiBXException("Error creating writer", e);
        }
View Full Code Here

       
        // marshal bean back out to document in memory
        IMarshallingContext mctx = obf.createMarshallingContext();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            XMLOutputFactory ofact = XMLOutputFactory.newInstance();
            XMLStreamWriter wrtr = ofact.createXMLStreamWriter(bos, "UTF-8");
            mctx.setXmlWriter(new StAXWriter(obf.getNamespaces(), wrtr));
            mctx.marshalDocument(obj);
        } catch (XMLStreamException e) {
            throw new JiBXException("Error creating writer", e);
        }
View Full Code Here

        // #1 parse a query
        XQueryModule module = proc.parse(input);

        // prepare a result handler (StAX)
        Writer writer = new StringWriter();
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        XMLStreamWriter streamWriter = factory.createXMLStreamWriter(writer);
        XQEventReceiver handler = new StAXSerializer(streamWriter);

        // #2 execute the compiled expression using ``push'' mode
        //   In push mode, the result is directed to the events.
        proc.execute(module, handler);
View Full Code Here

  Formatter out = new Formatter(System.out);
  XMLStreamWriter staxWriter;

  void read2xml() throws IOException, XMLStreamException {
    XMLOutputFactory fac = XMLOutputFactory.newInstance();

    String fileout = "D:/bufr/out/test5.xml.gzip";
    FileOutputStream fos = new FileOutputStream(fileout);
    GZIPOutputStream zos = new GZIPOutputStream(fos);

    //staxWriter = fac.createXMLStreamWriter(System.out, "UTF-8");
    //staxWriter = fac.createXMLStreamWriter(fos, "UTF-8");
    staxWriter = fac.createXMLStreamWriter(zos, "UTF-8");

    staxWriter.writeStartDocument("UTF-8", "1.0");
    staxWriter.writeCharacters("\n");
    staxWriter.writeStartElement("bufrMessages");
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLOutputFactory

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.