public Export() { xmlf = (WstxOutputFactory) WstxOutputFactory.newInstance(); xmlf.configureForRobustness(); }
@Override public void writeToStream(Gexf gexf, Writer out, String encoding) throws IOException { try { XMLOutputFactory xmlOutputFactory = WstxOutputFactory.newInstance(); XMLStreamWriter streamWriter = xmlOutputFactory.createXMLStreamWriter(out); PrettyPrintHandler handler = new PrettyPrintHandler(streamWriter); streamWriter = (XMLStreamWriter) Proxy.newProxyInstance( XMLStreamWriter.class.getClassLoader(), new Class[]{XMLStreamWriter.class}, handler ); streamWriter.writeStartDocument(encoding, "1.0"); new GexfEntityWriter(streamWriter, gexf); streamWriter.writeEndDocument(); streamWriter.flush(); streamWriter.close(); } catch (XMLStreamException e) { throw new IOException("XML Exception: " + e.getMessage(), e); } }
protected WstxOutputFactory getXMLFactory() { // initialize outputs System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory"); WstxOutputFactory xmlw = (WstxOutputFactory) WstxOutputFactory .newInstance(); xmlw.configureForRobustness(); xmlw.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); xmlw.setProperty(WstxOutputProperties.P_OUTPUT_FIX_CONTENT, true); xmlw.setProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT, true); return xmlw; }
/** * Configures XML Output Factory * * @return WstxOutputFactory */ protected WstxOutputFactory getXMLFactory() { // initialise outputs System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory"); WstxOutputFactory xmlw = (WstxOutputFactory) WstxOutputFactory .newInstance(); xmlw.configureForRobustness(); // configure factory xmlw.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); xmlw.setProperty(WstxOutputProperties.P_OUTPUT_FIX_CONTENT, true); xmlw.setProperty(WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT, true); return xmlw; }