/** * Set the current {@link Format} to be used for output. * * @param format * the new Format */ public void setFormat(Format format) { this.format = format == null ? Format.getRawFormat() : format; }
/** * Set a new Format instance for this DOMOutputter * * @param format * the new Format instance to use (null implies the default) * @since JDOM2 */ public void setFormat(Format format) { this.format = format == null ? Format.getRawFormat() : format; }
/** * The complete constructor for specifying a custom DOMAdaptor, Format, and * DOMOutputProcessor. * * @param adapter * The adapter to use to create the base Document instance (null * implies the default). * @param format * The output Format to use (null implies the default). * @param processor * The custom mechanism for doing the output (null implies the * default). * @since JDOM2 */ public DOMOutputter(DOMAdapter adapter, Format format, DOMOutputProcessor processor) { this.adapter = adapter == null ? DEFAULT_ADAPTER : adapter; this.format = format == null ? Format.getRawFormat() : format; this.processor = processor == null ? DEFAULT_PROCESSOR : processor; }
LexicalHandler lexicalHandler) { this.processor = processor == null ? DEFAULT_PROCESSOR : processor; this.format = format == null ? Format.getRawFormat() : format; this.contentHandler = contentHandler; this.errorHandler = errorHandler;
/** * This will create an <code>XMLOutputter</code> with the specified format * characteristics. * <p> * <b>Note:</b> the format object is cloned internally before use. If you * want to modify the Format after constructing the XMLOutputter you can * modify the Format instance {@link #getFormat()} returns. * * @param format * The Format instance to use. This instance will be cloned() and as * a consequence, changes made to the specified format instance * <b>will not</b> be reflected in this XMLOutputter. A null input * format indicates that XMLOutputter should use the default * {@link Format#getRawFormat()} * @param processor * The XMLOutputProcessor to delegate output to. If null the * XMLOutputter will use the default XMLOutputProcessor. */ public XMLOutputter(Format format, XMLOutputProcessor processor) { myFormat = format == null ? Format.getRawFormat() : format.clone(); myProcessor = processor == null ? DEFAULTPROCESSOR : processor; }
/** * This will create an <code>StAXStreamOutputter</code> with the specified format * characteristics. * <p> * <b>Note:</b> the format object is cloned internally before use. If you * want to modify the Format after constructing the StAXStreamOutputter you can * modify the Format instance {@link #getFormat()} returns. * * @param format * The Format instance to use. This instance will be cloned() and as * a consequence, changes made to the specified format instance * <b>will not</b> be reflected in this StAXStreamOutputter. A null input * format indicates that StAXStreamOutputter should use the default * {@link Format#getRawFormat()} * @param processor * The XMLOutputProcessor to delegate output to. If null the * StAXStreamOutputter will use the default XMLOutputProcessor. */ public StAXStreamOutputter(Format format, StAXStreamProcessor processor) { myFormat = format == null ? Format.getRawFormat() : format.clone(); myProcessor = processor == null ? DEFAULTPROCESSOR : processor; }
/** * This will create an <code>StAXStreamOutputter</code> with the specified format * characteristics. * <p> * <b>Note:</b> the format object is cloned internally before use. If you * want to modify the Format after constructing the StAXStreamOutputter you can * modify the Format instance {@link #getFormat()} returns. * * @param format * The Format instance to use. This instance will be cloned() and as * a consequence, changes made to the specified format instance * <b>will not</b> be reflected in this StAXStreamOutputter. A null input * format indicates that StAXStreamOutputter should use the default * {@link Format#getRawFormat()} * @param processor * The XMLOutputProcessor to delegate output to. If null the * StAXStreamOutputter will use the default XMLOutputProcessor. * @param eventfactory * The factory to use to create XMLEvent instances. */ public StAXEventOutputter(Format format, StAXEventProcessor processor, XMLEventFactory eventfactory) { myFormat = format == null ? Format.getRawFormat() : format.clone(); myProcessor = processor == null ? DEFAULTPROCESSOR : processor; myEventFactory = eventfactory == null ? DEFAULTEVENTFACTORY : eventfactory; }
public IString xmlRaw(IConstructor node) throws IOException { return xmlToString(node, Format.getRawFormat()); }
void output( @Nonnull final Document document, @Nonnull final File outputFile ) throws IOException { try( final FileOutputStream fileOutputStream = new FileOutputStream(outputFile) ) { new XMLOutputter(Format.getRawFormat()).output(document, fileOutputStream); } } }
public static String documentToRawString(Document xml) throws IOException { return documentToString(xml, Format.getRawFormat().setOmitDeclaration(true)).trim(); }
public static synchronized void writeXml(String dirName, String fileName, String content) { logger.debug("Writing Xml to "+dirName+"/"+fileName); try { Reader sr = new StringReader(content); Document doc = new SAXBuilder().build(sr); XMLOutputter xmlOut = new XMLOutputter(Format.getRawFormat() ); File f = new File(dirName+"/"+fileName); OutputStream os = new FileOutputStream(f); OutputStreamWriter osw = new OutputStreamWriter(os,"UTF-8"); xmlOut.output( doc, osw ); osw.close();os.close(); } catch (JDOMException e) {logger.error("",e);} catch (IOException e) {logger.error("",e);} }
public void createIds(File srcFile, File dstFile) throws OfxInternalProcessingException { if(srcFile==null){throw new OfxInternalProcessingException("FileNoteFound: "+srcFile.getAbsolutePath());} doc = JDomUtil.load(srcFile); if(doc==null){throw new OfxInternalProcessingException("FileNoteFound: "+srcFile.getAbsolutePath());} try { idCreator(); JDomUtil.save(doc, dstFile, Format.getRawFormat()); } catch (JDOMException e) { logger.error("",e); } }
/** * Method write * * @param project * @param writer * @param document */ public void write( Model project, Document document, OutputStreamWriter writer ) throws java.io.IOException { Format format = Format.getRawFormat(); format.setEncoding( writer.getEncoding() ).setLineSeparator( System.getProperty( "line.separator" ) ); write( project, document, writer, format ); } // -- void write(Model, Document, OutputStreamWriter)
@Override public String toString(Format format) { try { Element e = marshal(); XMLOutputter out = new XMLOutputter(Format.formatted.equals(format) ? org.jdom2.output.Format.getPrettyFormat() : org.jdom2.output.Format.getRawFormat()); StringWriter writer = new StringWriter(); out.output(e, writer); return writer.toString(); } catch (Exception exc) { throw new OAIImplementationException(exc); } }
public synchronized static StringBuffer toString(Wikiinjection injection) { StringBufferOutputStream sbos = new StringBufferOutputStream(); try { Element element = toElement(injection, Wikiinjection.class); XMLOutputter xmlOut = new XMLOutputter(Format.getRawFormat() ); xmlOut.output(element, sbos); } catch (IOException e) {logger.error("",e);} return sbos.getStringBuffer(); }
public void process() throws OfxInternalProcessingException, OfxConfigurationException { File fTemplateDir = getDir(WikiProcessor.WikiDir.wikiTemplate); for(File fTemplate : fTemplateDir.listFiles()) { try { Template template = (Template)JaxbUtil.loadJAXB(fTemplate.getAbsolutePath(), Template.class); File fOfxTemplate = new File(getDir(WikiProcessor.WikiDir.ofxTemplate),template.getId()+".xml"); Document doc = processTemplate(template); JDomUtil.save(doc, fOfxTemplate, Format.getRawFormat()); } catch (FileNotFoundException e) { throw new OfxInternalProcessingException(e.getMessage()); } } }
public void processPage(Page page) throws OfxAuthoringException, OfxInternalProcessingException { checkPageConfig(page); try { String srcName = page.getFile()+"."+WikiProcessor.WikiFileExtension.xhtml; String dstName = page.getFile()+"."+WikiProcessor.WikiFileExtension.xml; String txtMarkup = StringIO.loadTxt(srcDir, srcName); String result = process(txtMarkup, page.getName()); File fDst = new File(dstDir, dstName); Document doc = JDomUtil.txtToDoc(result); doc = checkTransparent(doc, page.getSection()); logger.warn("Content Trimmer deactivated here"); // doc = ofxContentTrimmer.trim(doc); JDomUtil.save(doc, fDst, Format.getRawFormat()); } catch (IOException e) {logger.error("",e);} catch (ParserConfigurationException e) {logger.error("",e);} catch (XMLStreamException e) {logger.error("",e);} catch (SAXException e) {logger.error("",e);} catch (JDOMException e) {logger.error("",e);} }
/** * {@inheritDoc} */ public String getString() throws IOException { m_document.setContext( m_context ); CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor(); XMLOutputter output = new XMLOutputter(processor); StringWriter out = new StringWriter(); Format fmt = Format.getRawFormat(); fmt.setExpandEmptyElements( false ); fmt.setLineSeparator( LINEBREAK ); output.setFormat( fmt ); output.outputElementContent( m_document.getRootElement(), out ); String result = out.toString(); return result; } }
/** * {@inheritDoc} */ public String getString() throws IOException { Element rootElement = m_document.getRootElement(); processChildren( rootElement ); m_document.setContext( m_context ); XMLOutputter output = new XMLOutputter(); StringWriter out = new StringWriter(); Format fmt = Format.getRawFormat(); fmt.setExpandEmptyElements( false ); fmt.setLineSeparator( LINEBREAK ); output.setFormat( fmt ); output.outputElementContent( m_document.getRootElement(), out ); return out.toString(); } }
Format format = Format.getRawFormat(); format.setLineSeparator( ls ); XMLOutputter out = new XMLOutputter( format );