public static WriterService createPassThroughService( OutputStream out, String encoding ) throws UnsupportedEncodingException { BufferedWriter bufferedWriter = new BufferedWriter( new OutputStreamWriter( out, encoding ) ); XmlWriter xmlWriter = new XmlWriter( bufferedWriter, createTagDefinitions() ); xmlWriter.addImpliedNamespace( HtmlPrinter.XHTML_NAMESPACE, "" ); xmlWriter.setHtmlCompatiblityMode( true ); WriterService writerService = new WriterService( bufferedWriter ); writerService.setXmlWriter( xmlWriter ); return writerService; }
public XmlWriter createHeaderXmlWriter() { if ( isBuffered() == false ) { throw new IllegalStateException(); } final XmlWriter docWriter = new XmlWriter( writer, xmlWriter.getTagDescription() ); docWriter.addImpliedNamespace( HtmlPrinter.XHTML_NAMESPACE, "" ); docWriter.setHtmlCompatiblityMode( true ); return docWriter; }
public static WriterService createBufferedService( OutputStream out, String encoding ) throws UnsupportedEncodingException { MemoryStringWriter bufferWriter = new MemoryStringWriter( 1024 * 512 ); XmlWriter xmlWriter = new XmlWriter( bufferWriter, createTagDefinitions() ); xmlWriter.setAdditionalIndent( 1 ); xmlWriter.addImpliedNamespace( HtmlPrinter.XHTML_NAMESPACE, "" ); xmlWriter.setHtmlCompatiblityMode( true ); BufferedWriter bufferedWriter = new BufferedWriter( new OutputStreamWriter( out, encoding ) ); WriterService writerService = new WriterService( bufferedWriter, bufferWriter ); writerService.setXmlWriter( xmlWriter ); return writerService; }
public static String writeImageMapAsString( final ImageMap imageMap ) { try { final DefaultTagDescription tagDescription = new DefaultTagDescription(); tagDescription.setDefaultNamespace( LibXmlInfo.XHTML_NAMESPACE ); tagDescription.setNamespaceHasCData( LibXmlInfo.XHTML_NAMESPACE, false ); final StringWriter sbwriter = new StringWriter( 5000 ); final XmlWriter writer = new XmlWriter( sbwriter ); writer.setHtmlCompatiblityMode( true ); writer.setWriteFinalLinebreak( true ); writeImageMap( writer, imageMap, 1 ); writer.close(); return sbwriter.toString(); } catch ( IOException ioe ) { // now where does a StringWriter get its IO troubles from? throw new IllegalStateException( "Failed to write ImageMap - I am confused." ); } }
final DefaultTagDescription tagDescription = new DefaultTagDescription(); final XmlWriter xmlWriter = new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); final AttributeList rootAttrs = new AttributeList(); rootAttrs.addNamespaceDeclaration( "data", ExternalDataFactoryModule.NAMESPACE );
public String writeReport( final WriteableDocumentBundle bundle, final BundleWriterState state ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( state == null ) { throw new NullPointerException(); } final OutputStream outputStream = new BufferedOutputStream( bundle.createEntry( "settings.xml", "text/xml" ) ); final DefaultTagDescription tagDescription = BundleWriterHandlerRegistry.getInstance().createWriterTagDescription(); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); writer.writeXmlDeclaration( "UTF-8" ); final AttributeList rootAttributes = new AttributeList(); rootAttributes.addNamespaceDeclaration( "", BundleNamespaces.SETTINGS ); writer.writeTag( BundleNamespaces.SETTINGS, "settings", rootAttributes, XmlWriterSupport.OPEN ); writeConfiguration( state, writer ); writeRuntimeInformation( state, writer ); writer.writeCloseTag(); writer.close(); return "settings.xml"; }
public void open() throws IOException { final DefaultTagDescription td = new DefaultTagDescription(); td.setNamespaceHasCData( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, false ); td.setElementHasCData( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "text", true ); // prepare anything that might needed to be prepared .. final String encoding = metaData.getConfiguration().getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.xml.Encoding", EncodingRegistry.getPlatformDefaultEncoding() ); final Writer writer = new BufferedWriter( new OutputStreamWriter( outputStream, encoding ) ); this.xmlWriter = new XmlWriter( writer, td ); this.xmlWriter.writeXmlDeclaration( encoding ); final AttributeList attrs = new AttributeList(); attrs.addNamespaceDeclaration( "", XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE ); xmlWriter.writeTag( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "layout-output", attrs, XmlWriter.OPEN ); }
public void open() throws IOException { final DefaultTagDescription td = new DefaultTagDescription(); td.setNamespaceHasCData( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, false ); td.setElementHasCData( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "text", true ); // prepare anything that might needed to be prepared .. final String encoding = metaData.getConfiguration().getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xml.Encoding", EncodingRegistry.getPlatformDefaultEncoding() ); final Writer writer = new BufferedWriter( new OutputStreamWriter( outputStream, encoding ) ); this.xmlWriter = new XmlWriter( writer, td ); this.xmlWriter.writeXmlDeclaration( null ); final AttributeList attrs = new AttributeList(); attrs.addNamespaceDeclaration( "", XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE ); xmlWriter.writeTag( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "layout-output", attrs, XmlWriter.OPEN ); }
/** * Writes a report to a character stream writer. * * @param w * the character stream writer. * @throws IOException * if there is an I/O problem. * @throws ReportWriterException * if there is a problem writing the report. */ public void write( final Writer w ) throws IOException, ReportWriterException { final XmlWriter xmlWriter = new XmlWriter( w, createTagDescription() ); xmlWriter.writeXmlDeclaration( getEncoding() ); final ReportDefinitionWriter writer = new ReportDefinitionWriter( this, xmlWriter ); writer.write(); }
new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); xmlWriter.writeXmlDeclaration( "UTF-8" );
final DefaultTagDescription tagDescription = BundleWriterHandlerRegistry.getInstance().createWriterTagDescription(); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); writer.writeXmlDeclaration( "UTF-8" );
final DefaultTagDescription tagDescription = BundleWriterHandlerRegistry.getInstance().createWriterTagDescription(); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); writer.writeXmlDeclaration( "UTF-8" );
public void write( final IDatabaseConnection[] connections, final OutputStream out ) throws IOException { DefaultTagDescription tagDescription = new DefaultTagDescription(); tagDescription.setDefaultNamespace( ConnectionModule.NAMESPACE ); tagDescription.setNamespaceHasCData( ConnectionModule.NAMESPACE, false ); tagDescription.setElementHasCData( ConnectionModule.NAMESPACE, "attribute", true ); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( out, "UTF-8" ), tagDescription ); writer.writeXmlDeclaration( "UTF-8" ); final AttributeList rootList = new AttributeList(); rootList.addNamespaceDeclaration( null, ConnectionModule.NAMESPACE ); writer.writeTag( ConnectionModule.NAMESPACE, "connections", rootList, XmlWriter.OPEN ); for ( int i = 0; i < connections.length; i++ ) { final IDatabaseConnection connection = connections[i]; write( connection, writer ); } writer.writeCloseTag(); writer.flush(); }
@Test public void testStartParsing() { StringWriter stringWriter = new StringWriter(); XmlWriter writer = new XmlWriter( stringWriter ); writer.addImpliedNamespace( "http://reporting.pentaho.org/namespaces/engine/classic/bundle/style/1.0", "rep" ); ElementStyleSheet sheet = new ElementStyleSheet(); sheet.setBooleanStyleProperty( TextStyleKeys.WORDBREAK, false ); try { StyleWriterUtility.writeTextStyles( writer, sheet ); } catch (IOException e) { e.printStackTrace(); Assert.fail(); } String res = stringWriter.toString().replace( "\r", "" ).replace( "\n", "" ); Assert.assertEquals( "<rep:text-styles word-break=\"false\"/>", res ); } }
new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); xmlWriter.writeXmlDeclaration( "UTF-8" );
new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); final AttributeList rootAttrs = new AttributeList(); rootAttrs.addNamespaceDeclaration( "data", SQLDataFactoryModule.NAMESPACE );
tagDescription.configure( LibDocBundleBoot.getInstance().getGlobalConfig(), CONFIG_PREFIX ); final XmlWriter writer = new XmlWriter ( new OutputStreamWriter( out, "UTF-8" ), tagDescription, " ", "\n" ); writer.setAlwaysAddNamespace( true );
tagDescription.configure( LibDocBundleBoot.getInstance().getGlobalConfig(), TAGDEF_CONFIG_PREFIX ); final XmlWriter writer = new XmlWriter ( new OutputStreamWriter( out, "UTF-8" ), tagDescription, " ", "\n" ); writer.setAlwaysAddNamespace( true );
public void write( final OutputStream outputStream, final ElementStyleDefinition styleDefinition ) throws IOException { final DefaultTagDescription tagDescription = BundleWriterHandlerRegistry.getInstance().createWriterTagDescription(); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( new NoCloseOutputStream( outputStream ), "UTF-8" ), tagDescription, " ", "\n" ); writer.writeXmlDeclaration( "UTF-8" ); final AttributeList rootAttributes = new AttributeList(); rootAttributes.addNamespaceDeclaration( "", BundleNamespaces.STYLE ); rootAttributes.addNamespaceDeclaration( "layout", BundleNamespaces.LAYOUT ); rootAttributes.addNamespaceDeclaration( "core", AttributeNames.Core.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "html", AttributeNames.Html.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "swing", AttributeNames.Swing.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "pdf", AttributeNames.Pdf.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "designtime", AttributeNames.Designtime.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "crosstab", AttributeNames.Crosstab.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "pentaho", AttributeNames.Pentaho.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "table", AttributeNames.Table.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "page", ExtParserModule.NAMESPACE ); writer.writeTag( BundleNamespaces.STYLE, "style-definition", rootAttributes, XmlWriter.OPEN ); StyleFileWriter.writeStyleDefinition( writer, styleDefinition ); writer.writeCloseTag(); writer.flush(); writer.close(); } }
final DefaultTagDescription tagDescription = new DefaultTagDescription(); tagDescription.setNamespaceHasCData( null, false ); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( System.out ), tagDescription );