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(); }
if ( xmlWriter.isNamespaceDefined( SQLDataFactoryModule.NAMESPACE ) == false ) { rootAttribs.addNamespaceDeclaration( "data", SQLDataFactoryModule.NAMESPACE ); xmlWriter.writeTag( SQLDataFactoryModule.NAMESPACE, "connection", rootAttribs, XmlWriterSupport.OPEN ); xmlWriter.writeTag( SQLDataFactoryModule.NAMESPACE, "driver", XmlWriterSupport.OPEN ); xmlWriter.writeTextNormalized( driverProvider.getDriver(), false ); xmlWriter.writeCloseTag(); xmlWriter.writeTag( SQLDataFactoryModule.NAMESPACE, "url", XmlWriterSupport.OPEN ); xmlWriter.writeTextNormalized( driverProvider.getUrl(), false ); xmlWriter.writeCloseTag(); xmlWriter.writeTag( SQLDataFactoryModule.NAMESPACE, "properties", XmlWriterSupport.OPEN ); final String[] propertyNames = driverProvider.getPropertyNames(); for ( int i = 0; i < propertyNames.length; i++ ) { final String name = propertyNames[i]; final String value = driverProvider.getProperty( name ); xmlWriter.writeTag( SQLDataFactoryModule.NAMESPACE, "property", "name", name, XmlWriterSupport.OPEN ); xmlWriter.writeTextNormalized( value, false ); xmlWriter.writeCloseTag(); xmlWriter.writeCloseTag(); xmlWriter.writeCloseTag();
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 void close() throws IOException { // close all .. xmlWriter.writeCloseTag(); xmlWriter.close(); }
protected void writeRuntimeInformation( final BundleWriterState state, final XmlWriter writer ) throws IOException { if ( state == null ) { throw new NullPointerException(); } if ( writer == null ) { throw new NullPointerException(); } writer.writeTag( BundleNamespaces.SETTINGS, "runtime", XmlWriterSupport.OPEN ); writer.writeCloseTag(); }
private void writeReportConfig( final Configuration config ) throws IOException { final XmlWriter writer = getXmlWriter(); final Enumeration properties = config.getConfigProperties(); if ( properties.hasMoreElements() ) { writer.writeTag( ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.CONFIGURATION_TAG, XmlWriterSupport.OPEN ); while ( properties.hasMoreElements() ) { final String key = (String) properties.nextElement(); final String value = config.getConfigProperty( key ); if ( value != null ) { writer.writeTag( ExtParserModule.NAMESPACE, "property", "name", key, XmlWriterSupport.OPEN ); writer.writeTextNormalized( value, false ); writer.writeCloseTag(); } } writer.writeCloseTag(); } }
tagDescription.configure( LibDocBundleBoot.getInstance().getGlobalConfig(), TAGDEF_CONFIG_PREFIX ); final XmlWriter writer = new XmlWriter ( new OutputStreamWriter( out, "UTF-8" ), tagDescription, " ", "\n" ); writer.setAlwaysAddNamespace( true ); writer.setWriteFinalLinebreak( true ); writer.writeXmlDeclaration( "UTF-8" ); rootAttributes.addNamespaceDeclaration( "meta", ODFMetaAttributeNames.Meta.NAMESPACE ); rootAttributes.addNamespaceDeclaration( "dc", ODFMetaAttributeNames.DublinCore.NAMESPACE ); writer.writeTag( OFFICE_NAMESPACE, "document-meta", rootAttributes, XmlWriterSupport.OPEN ); writer.writeTag( OFFICE_NAMESPACE, "meta", XmlWriterSupport.OPEN ); writer.writeCloseTag(); writer.writeCloseTag(); } finally { writer.flush();
if ( xmlWriter.isNamespaceDefined( StaticDataFactoryModule.NAMESPACE ) == false ) { rootAttrs.addNamespaceDeclaration( "data", StaticDataFactoryModule.NAMESPACE ); .writeTag( StaticDataFactoryModule.NAMESPACE, "direct-static-datasource", rootAttrs, XmlWriterSupport.OPEN ); xmlWriter.writeCloseTag();
docWriter.writeXmlDeclaration( encoding ); for ( int i = 0; i < XHTML_HEADER.length; i++ ) { docWriter.writeText( XHTML_HEADER[i] ); docWriter.writeNewLine(); docWriter.writeTag( XHTML_NAMESPACE, "html", XmlWriterSupport.OPEN ); docWriter.writeTag( XHTML_NAMESPACE, "head", XmlWriterSupport.OPEN ); docWriter.writeTag( XHTML_NAMESPACE, "title", XmlWriterSupport.OPEN ); docWriter.writeTextNormalized( title, false ); docWriter.writeCloseTag(); } else if ( sheetName != null ) { // if no single title defined, use the sheetname function previously computed docWriter.writeTag( XHTML_NAMESPACE, "title", XmlWriterSupport.OPEN ); docWriter.writeTextNormalized( sheetName, true ); docWriter.writeCloseTag(); } else { docWriter.writeTag( XHTML_NAMESPACE, "title", XmlWriterSupport.OPEN ); docWriter.writeText( " " ); docWriter.writeCloseTag(); metaAttrs.setAttribute( XHTML_NAMESPACE, "http-equiv", "content-type" ); metaAttrs.setAttribute( XHTML_NAMESPACE, "content", "text/html; charset=" + encoding ); docWriter.writeTag( XHTML_NAMESPACE, "meta", metaAttrs, XmlWriterSupport.CLOSE ); docWriter.writeTag( XHTML_NAMESPACE, "link", attrList, XmlWriterSupport.CLOSE ); } else if ( inlineStyleSheet != null ) { docWriter.writeTag( XHTML_NAMESPACE, "style", "type", "text/css", XmlWriterSupport.OPEN ); StringWriter writer = new StringWriter(); inlineStyleSheet.write( writer );
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 ); }
private void writeAnchors( final XmlWriter xmlWriter, final ReportElement realBackground ) throws IOException { if ( realBackground != null ) { final String[] anchors = new String[0]; // realBackground.getAnchors(); for ( int i = 0; i < anchors.length; i++ ) { final String anchor = anchors[i]; xmlWriter.writeTag( HtmlPrinter.XHTML_NAMESPACE, "a", "name", anchor, XmlWriterSupport.CLOSE ); } } }
protected void openSheet( final ReportAttributeMap logicalPage, final String sheetName, final OutputProcessorMetaData metaData, final SlimSheetLayout sheetLayout, final XmlWriter xmlWriter ) throws ContentIOException, URLRewriteException, IOException { setStyleManager( createStyleManager() ); generateExternalStylePlaceHolder(); generateHeaderOnOpen( logicalPage, sheetName, xmlWriter ); final Object rawContent = logicalPage.getAttribute( AttributeNames.Html.NAMESPACE, AttributeNames.Html.EXTRA_RAW_CONTENT ); if ( rawContent != null ) { xmlWriter.writeText( String.valueOf( rawContent ) ); } // table name if ( "true".equals( metaData.getConfiguration().getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.html.EnableSheetNameProcessing" ) ) ) { if ( sheetName != null ) { xmlWriter.writeTag( HtmlPrinter.XHTML_NAMESPACE, "h1", getTagHelper().createSheetNameAttributes(), XmlWriterSupport.OPEN ); xmlWriter.writeTextNormalized( sheetName, true ); xmlWriter.writeCloseTag(); } } // table xmlWriter.writeTag( HtmlPrinter.XHTML_NAMESPACE, "table", getTagHelper().createTableAttributes( sheetLayout, logicalPage ), XmlWriterSupport.OPEN ); writeColumnDeclaration( sheetLayout, xmlWriter ); }
protected void performCloseFile( final String sheetName, final ReportAttributeMap logicalPageBox, final WriterService writer ) throws IOException, ContentIOException { XmlWriter xmlWriter = writer.getXmlWriter(); xmlWriter.writeCloseTag(); // for the opening table .. xmlWriter.writeText( String.valueOf( rawFooterContent ) ); xmlWriter.close(); return; xmlWriter.writeCloseTag(); // for the body tag xmlWriter.writeCloseTag(); // for the HTML tag xmlWriter.close(); return; xmlWriter.writeCloseTag(); // for the body tag xmlWriter.writeCloseTag(); // for the HTML tag xmlWriter.close(); return; xmlWriter.writeCloseTag(); // for the body .. xmlWriter.flush(); docWriter.writeStream( stringReader ); stringReader.close(); docWriter.writeCloseTag(); // for the html .. docWriter.close();
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 ); xmlWriter.writeTag( ExternalDataFactoryModule.NAMESPACE, "external-datasource", rootAttrs, XmlWriterSupport.CLOSE ); xmlWriter.close();
final DefaultTagDescription tagDescription = BundleWriterHandlerRegistry.getInstance().createWriterTagDescription(); final XmlWriter writer = new XmlWriter( new OutputStreamWriter( outputStream, "UTF-8" ), tagDescription, " ", "\n" ); writer.writeXmlDeclaration( "UTF-8" ); writer.close(); return layoutFileState.getFileName();
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." ); } }
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; }
/** * 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(); }
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; }
if ( writer.isNamespaceDefined( entryNamespace ) == false ) { final String defaultNamespace = bundleWriter.getDefaultPrefix( entryNamespace ); if ( defaultNamespace != null && writer.isNamespacePrefixDefined( defaultNamespace ) == false ) { attributeList.addNamespaceDeclaration( defaultNamespace, entryNamespace ); } else { ( ODFMetaAttributeNames.Meta.NAMESPACE, "character-count", String.valueOf( statistic.getCharacterCount() ) ); writer.writeTag( entryNamespace, entryName, attributeList, XmlWriterSupport.CLOSE );