Package javax.xml.stream

Examples of javax.xml.stream.XMLStreamWriter


    private XMLStreamWriter createWriter(StringWriter stringWriter) {
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);

        try {
            XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(stringWriter);
            xmlWriter.writeStartDocument("UTF-8", "1.0");
            return xmlWriter;
        } catch (XMLStreamException ex) {
            Exceptions.printStackTrace(ex);
        }
        return null;
View Full Code Here


            //Create Writer and write project
            XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
            outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);
            BufferedOutputStream bufferedOutputStream=new BufferedOutputStream(zipOut);
            XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bufferedOutputStream, "UTF-8");
            gephiWriter.writeAll(project, writer);
            writer.close();

            //Close
            zipOut.closeEntry();
            zipOut.finish();
            bufferedOutputStream.close();
View Full Code Here

        try {
            XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
            outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);

            XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(writer);
            xmlWriter = new IndentingXMLStreamWriter(xmlWriter);

            xmlWriter.writeStartDocument("UTF-8", "1.0");
            xmlWriter.setPrefix("", GEXF_NAMESPACE);
            xmlWriter.writeStartElement(GEXF_NAMESPACE, GEXF);
            xmlWriter.writeNamespace("", GEXF_NAMESPACE);
            xmlWriter.writeAttribute(GEXF_VERSION, "1.1");

            if (exportColors || exportPosition || exportSize) {
                xmlWriter.writeNamespace(VIZ, VIZ_NAMESPACE);
            }
            xmlWriter.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            xmlWriter.writeAttribute("xsi:schemaLocation", GEXF_NAMESPACE_LOCATION);

            if (exportDynamic) {
                DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
                dynamicModel = dynamicController != null ? dynamicController.getModel(workspace) : null;
                visibleInterval = dynamicModel == null ? null : exportVisible ? dynamicModel.getVisibleInterval() : new TimeInterval(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
            }

            writeMeta(xmlWriter);
            writeGraph(xmlWriter, graph);

            xmlWriter.writeEndElement();
            xmlWriter.writeEndDocument();
            xmlWriter.close();

        } catch (Exception e) {
            graph.readUnlockAll();
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
View Full Code Here

    private XMLStreamWriter createWriter(StringWriter stringWriter) {
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);

        try {
            XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(stringWriter);
            xmlWriter.writeStartDocument("UTF-8", "1.0");
            return xmlWriter;
        } catch (XMLStreamException ex) {
            Exceptions.printStackTrace(ex);
        }
        return null;
View Full Code Here

     */
    public XMLStreamWriter2 createStax2Writer(File f)
        throws XMLStreamException
    {
        Stax2FileResult res = new Stax2FileResult(f);
        XMLStreamWriter sw = mStax2Factory.createXMLStreamWriter(res);
        return Stax2WriterAdapter.wrapIfNecessary(sw);
    }
View Full Code Here

        graphDistance.execute(graphModel, attributeModel);
        model.addReport(graphDistance);

        try {
            StringWriter stringWriter = new StringWriter();
            XMLStreamWriter writer = createWriter(stringWriter);
            model.writeXML(writer);
            writer.close();
            String s1 = stringWriter.toString();
            StatisticsModelImpl model2 = new StatisticsModelImpl();
            StringReader stringReader = new StringReader(s1);
            XMLStreamReader reader = createReader(stringReader);
            model2.readXML(reader);
            reader.close();
            stringWriter = new StringWriter();
            writer = createWriter(stringWriter);
            model2.writeXML(writer);
            writer.close();
            String s2 = stringWriter.toString();
            assertEquals(s1, s2);
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

    private XMLStreamWriter createWriter(StringWriter stringWriter) {
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);

        try {
            XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(stringWriter);
            xmlWriter.writeStartDocument("UTF-8", "1.0");
            return xmlWriter;
        } catch (XMLStreamException ex) {
            Exceptions.printStackTrace(ex);
        }
        return null;
View Full Code Here

  public void generateSchema(SchemaOutputResolver outputResolver)
    throws IOException
  {
    Result result = outputResolver.createOutput("", "schema1.xsd");

    XMLStreamWriter out = null;
   
    try {
      XMLOutputFactory factory = getXMLOutputFactory();
      out = factory.createXMLStreamWriter(result);

      out.writeStartDocument("UTF-8", "1.0");

      out.writeStartElement("xsd", "schema", XML_SCHEMA_NS);
      out.writeAttribute("version", "1.0");

      generateSchemaWithoutHeader(out);

      out.writeEndElement(); // schema
    }
    catch (Exception e) {
      IOException ioException = new IOException();

      ioException.initCause(e);

      throw ioException;
    }
    finally {
      try {
        out.close();
      }
      catch (XMLStreamException e) {
        throw new IOException(e.toString());
      }
    }
View Full Code Here

      return property.read(u, in, null);
    }
    else {
      DOMResult result = new DOMResult();
      XMLOutputFactory factory = _context.getXMLOutputFactory();
      XMLStreamWriter out = factory.createXMLStreamWriter(result);

      StaxUtil.copyReaderToWriter(in, out);

      Node node = result.getNode();
View Full Code Here

  {
    if (! _context.createJAXBIntrospector().isElement(obj))
      throw new MarshalException(L.l("Object is not a JAXB element: {0}", obj));

    try {
      XMLStreamWriter out = _xmlOutputFactory.createXMLStreamWriter(result);

      marshal(obj, out);

      out.flush();
    }
    catch (XMLStreamException e) {
      throw new JAXBException(e);
    }
  }
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLStreamWriter

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.