public String toString() { // TODO: WARNING! Later versions of plexus-utils psit out an <?xml ?> header due to thinking this is a new // document - not the desired behaviour! StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new PrettyPrintXMLWriter( writer, "UTF-8", null ); Xpp3DomWriter.write( xmlWriter, this ); return writer.toString(); }
writer.writeText( writer.getLineIndenter() ); hasComment = false; writer.startElement( parser.getName() ); for ( int i = 0; i < parser.getAttributeCount(); i++ ) writer.addAttribute( key, value ); writer.writeText( text ); writer.endElement(); writer.writeMarkup( writer.getLineSeparator() ); for ( int i = 0; i < writer.getDepth(); i++ ) writer.writeMarkup( writer.getLineIndenter() ); writer.writeMarkup( "<!--" + parser.getText().trim() + " -->" ); if ( !hasTag ) writer.writeMarkup( writer.getLineSeparator() ); for ( int i = 0; i < writer.getDepth() - 1; i++ ) writer.writeMarkup( writer.getLineIndenter() ); writer.writeMarkup( "<!DOCTYPE" + parser.getText() + ">" ); writer.endOfLine(); writer.writeMarkup( "<?" + parser.getText() + "?>" );
PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer ); xmlWriter.setLineIndenter( StringUtils.repeat( " ", indentSize ) ); xmlWriter.setLineSeparator( lineSeparator );
PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter( fileWriter, "UTF-8", null ); writer.startElement( "itext" ); writer.addAttribute( "creationdate", DateFormat.getDateTimeInstance().format( new Date() ) ); writer.addAttribute( "producer", "Doxia iText" ); writer.endElement(); // itext
PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter( out ); writer.startElement( "dependency" ); writer.startElement( "groupId" ); writer.writeText( artifact.getGroupId() ); writer.endElement(); writer.startElement( "artifactId" ); writer.writeText( artifact.getArtifactId() ); writer.endElement(); writer.startElement( "version" ); writer.writeText( artifact.getBaseVersion() ); if ( !StringUtils.isBlank( artifact.getClassifier() ) ) writer.startElement( "classifier" ); writer.writeText( artifact.getClassifier() ); writer.endElement(); writer.endElement(); writer.startElement( "scope" ); writer.writeText( artifact.getScope() ); writer.endElement(); writer.endElement();
/** * Write a chapter. * * @param writer the writer. * @param chapter the Chapter. * @param context the BookContext. * @throws BookDoxiaException if the chapter cannot be written. */ private void renderChapter( Sink sink, PrettyPrintXMLWriter writer, Chapter chapter, BookContext context ) throws BookDoxiaException { writer.startElement( "chapter" ); writer.addAttribute( "numberdepth", "1" ); writer.addAttribute( "depth", "1" ); writer.addAttribute( "indent", "1" ); startTitle( writer, "36.0", "Helvetica", "24.0", "normal", "255", "0", "0" ); chunk( writer, chapter.getTitle(), "Helvetica", "24.0", "normal", "255", "0", "0" ); writer.endElement(); // title // writer.startElement( "sectioncontent" ); for ( Section section : chapter.getSections() ) { renderSection( sink, writer, section, context ); } // writer.endElement(); // sectioncontent writer.endElement(); // chapter }
String red, String green, String blue ) writer.startElement( "chunk" ); writer.addAttribute( "font", font ); writer.addAttribute( "size", size ); writer.addAttribute( "fontstyle", fontstyle ); writer.addAttribute( "red", red ); writer.addAttribute( "green", green ); writer.addAttribute( "blue", blue ); if ( StringUtils.isNotEmpty( title ) ) writer.writeText( title ); writer.writeText( "<Missing title>" ); writer.endElement(); // chunk
/** * Start a title. * * @param writer the writer. * @param leading leading. * @param font the font. * @param size the size. * @param fontstyle the fontstyle. * @param red red. * @param green green. * @param blue blue. */ private void startTitle( PrettyPrintXMLWriter writer, String leading, String font, String size, String fontstyle, String red, String green, String blue ) { writer.startElement( "title" ); writer.addAttribute( "leading", leading ); writer.addAttribute( "font", font ); writer.addAttribute( "size", size ); writer.addAttribute( "fontstyle", fontstyle ); writer.addAttribute( "red", red ); writer.addAttribute( "green", green ); writer.addAttribute( "blue", blue ); }
/** {@inheritDoc} */ public void writeText( String text ) { writeText( text, true ); }
/** {@inheritDoc} */ protected void writeEndTag( Tag t ) { if ( this.tableCaptionXMLWriterStack.isEmpty() ) { super.writeEndTag( t ); } else { this.tableCaptionXMLWriterStack.getLast().endElement(); } }
XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null ); new OutputStreamWriter( new FileOutputStream( new File( config.getEclipseProjectDirectory(), "maven-eclipse.xml" ) ), "UTF-8" ); PrettyPrintXMLWriter buildXmlPrinter = new PrettyPrintXMLWriter( buildXmlWriter ); buildXmlPrinter.startElement( "project" ); buildXmlPrinter.addAttribute( "default", "copy-resources" ); buildXmlPrinter.startElement( "target" ); buildXmlPrinter.addAttribute( NAME, "init" ); buildXmlPrinter.endElement(); buildXmlPrinter.startElement( "target" ); buildXmlPrinter.addAttribute( NAME, "copy-resources" ); buildXmlPrinter.addAttribute( "depends", "init" ); buildXmlPrinter.startElement("copy"); buildXmlPrinter.addAttribute("todir", dir.getOutput()); buildXmlPrinter.addAttribute("filtering", "" + dir.isFiltering()); buildXmlPrinter.startElement("fileset"); buildXmlPrinter.addAttribute("dir", dir.getPath()); if (dir.getIncludeAsString() != null) { buildXmlPrinter.addAttribute("includes", dir.getIncludeAsString()); buildXmlPrinter.addAttribute("excludes", dir.getExcludeAsString());
writer = new OutputStreamWriter( os ); final PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer ); xmlWriter.setLineIndenter( StringUtils.repeat( " ", indentSize ) ); xmlWriter.setLineSeparator( lineSeparator );
/** {@inheritDoc} */ protected void writeStartTag( Tag t, MutableAttributeSet att, boolean isSimpleTag ) { if ( this.tableCaptionXMLWriterStack.isEmpty() ) { super.writeStartTag ( t, att, isSimpleTag ); } else { String tag = ( getNameSpace() != null ? getNameSpace() + ":" : "" ) + t.toString(); this.tableCaptionXMLWriterStack.getLast().startElement( tag ); if ( att != null ) { Enumeration<?> names = att.getAttributeNames(); while ( names.hasMoreElements() ) { Object key = names.nextElement(); Object value = att.getAttribute( key ); this.tableCaptionXMLWriterStack.getLast().addAttribute( key.toString(), value.toString() ); } } if ( isSimpleTag ) { this.tableCaptionXMLWriterStack.getLast().endElement(); } } }
/** {@inheritDoc} */ public void writeMarkup( String text ) { writeText( text, false ); }
public String toUnescapedString() { // TODO: WARNING! Later versions of plexus-utils psit out an <?xml ?> header due to thinking this is a new // document - not the desired behaviour! StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new PrettyPrintXMLWriter( writer, "UTF-8", null ); Xpp3DomWriter.write( xmlWriter, this, false ); return writer.toString(); }
/** * {@inheritDoc} * * Writes a text, swallowing any exceptions. */ protected void write( String text ) { if ( !this.tableCaptionXMLWriterStack.isEmpty() && this.tableCaptionXMLWriterStack.getLast() != null ) { this.tableCaptionXMLWriterStack.getLast().writeText( unifyEOLs( text ) ); } else if ( !this.tableContentWriterStack.isEmpty() && this.tableContentWriterStack.getLast() != null ) { this.tableContentWriterStack.getLast().write( unifyEOLs( text ) ); } else { out.write( unifyEOLs( text ) ); } }
public static void write( Writer writer, Xpp3Dom dom ) { write( new PrettyPrintXMLWriter( writer ), dom ); }
public static void write( PrintWriter writer, Xpp3Dom dom ) { write( new PrettyPrintXMLWriter( writer ), dom ); }
private XmlWriterXdocSink( StringWriter out, String encoding ) { super( out, encoding ); this.xdocWriter = out; this.xmlWriter = new PrettyPrintXMLWriter( out ); }
protected XMLWriter initializeXmlWriter(final Writer writer, final String docType) { return new PrettyPrintXMLWriter(writer, encoding, docType); }