Package org.pentaho.reporting.libraries.xmlns.writer

Examples of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter


   * @throws ReportWriterException if there is a problem writing the report.
   */
  private void writeGroups()
      throws IOException, ReportWriterException
  {
    final XmlWriter writer = getXmlWriter();
    writer.writeTag(ExtParserModule.NAMESPACE, ReportDescriptionWriter.GROUPS_TAG, XmlWriterSupport.OPEN);

    //logComment = true;
    final int groupSize = getReport().getGroupCount();
    for (int i = 0; i < groupSize; i++)
    {

      // This will fail for crosstabs. But this code is legacy, so it is ok.
      final RelationalGroup g = (RelationalGroup) getReport().getGroup(i);
      writer.writeTag(ExtParserModule.NAMESPACE, ReportDescriptionWriter.GROUP_TAG,
          "name", g.getName(), XmlWriterSupport.OPEN);

      final List fields = g.getFields();
      if (fields.isEmpty() == false)
      {
        writer.writeTag(ExtParserModule.NAMESPACE, ReportDescriptionWriter.FIELDS_TAG, XmlWriterSupport.OPEN);

        for (int f = 0; f < fields.size(); f++)
        {
          final String field = (String) fields.get(f);
          writer.writeTag(ExtParserModule.NAMESPACE, ReportDescriptionWriter.FIELD_TAG, XmlWriterSupport.OPEN);
          writer.writeTextNormalized(field, false);
          writer.writeCloseTag();
        }
        writer.writeCloseTag();
      }
      else
      {
        writer.writeTag(ExtParserModule.NAMESPACE, ReportDescriptionWriter.FIELDS_TAG, XmlWriterSupport.CLOSE);
      }

      writeRootBand(ReportDescriptionWriter.GROUP_HEADER_TAG, g.getHeader());
      writeRootBand(ReportDescriptionWriter.GROUP_FOOTER_TAG, g.getFooter());

      writer.writeCloseTag();
    }

    writer.writeCloseTag();
  }
View Full Code Here


   *                             if the report serialisation failed.
   */
  public void write() throws IOException, ReportWriterException
  {
    final SubReport report = (SubReport) getReport();
    final XmlWriter xmlWriter = getXmlWriter();

    final AttributeList attList = new AttributeList();
    if (getReportWriter().hasParent() == false)
    {
      attList.addNamespaceDeclaration("", ExtParserModule.NAMESPACE);
    }

    final String query = report.getQuery();
    if (query != null)
    {
      attList.setAttribute(ExtParserModule.NAMESPACE, "query", query);
    }
    xmlWriter.writeTag(ExtParserModule.NAMESPACE,
        "sub-report", attList, XmlWriterSupport.OPEN);

    writeParameterDeclaration();

    // no need to write the parser config, if this subreport is inlined.
    if (getReportWriter().hasParent() == false)
    {
      final ParserConfigWriter parserConfigWriter =
          new ParserConfigWriter(getReportWriter(), xmlWriter);
      parserConfigWriter.write();
    }

    final ReportConfigWriter reportConfigWriter =
        new ReportConfigWriter(getReportWriter(), xmlWriter);
    reportConfigWriter.write();

    final ReportDescriptionWriter reportDescriptionWriter
        = new ReportDescriptionWriter(getReportWriter(), xmlWriter);
    reportDescriptionWriter.write();

    final FunctionsWriter functionsWriter =
        new FunctionsWriter(getReportWriter(), xmlWriter);
    functionsWriter.write();
    xmlWriter.writeCloseTag();
  }
View Full Code Here

    {
      throw new ReportWriterException("The datasource type is not registered: "
          + ds.getClass());
    }

    final XmlWriter writer = getXmlWriter();
    writer.writeTag(ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.DATASOURCE_TAG,
        "type", dsname, XmlWriterSupport.OPEN);

    final DataSourceWriter dsWriter =
        new DataSourceWriter(getReportWriter(), ds, dsDesc, writer);
    dsWriter.write();
    writer.writeCloseTag();
  }
View Full Code Here

  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 ..

    final Object rawFooterContent = logicalPageBox.getAttribute(AttributeNames.Html.NAMESPACE,
        AttributeNames.Html.EXTRA_RAW_FOOTER_CONTENT);
    if (rawFooterContent != null)
    {
      xmlWriter.writeText(String.valueOf(rawFooterContent));
    }

    if (isCreateBodyFragment())
    {
      xmlWriter.close();
      return;
    }

    ContentItem styleFile = getStyleFile();
    if (styleFile != null)
    {
      final String encoding = getConfiguration().getConfigProperty
          (HtmlTableModule.ENCODING, EncodingRegistry.getPlatformDefaultEncoding());
      final Writer styleOut = new OutputStreamWriter
          (new BufferedOutputStream(styleFile.getOutputStream()), encoding);
      getStyleManager().write(styleOut);
      styleOut.flush();
      styleOut.close();

      if (isForceBufferedWriting() == false)
      {
        // A complete header had been written when the processing started ..
        xmlWriter.writeCloseTag(); // for the body tag
        xmlWriter.writeCloseTag(); // for the HTML tag
        xmlWriter.close();
        return;
      }
    }
    if (isInlineStylesRequested())
    {
      xmlWriter.writeCloseTag(); // for the body tag
      xmlWriter.writeCloseTag(); // for the HTML tag
      xmlWriter.close();
      return;
    }

    // handle external stylesheets. They need to be injected into the header.

    // finish the body fragment
    xmlWriter.writeCloseTag(); // for the body ..
    xmlWriter.flush();

    final XmlWriter docWriter = writer.createHeaderXmlWriter();
    if (styleFile != null)
    {
      // now its time to write the header with the link to the style-sheet-file
      writeCompleteHeader(docWriter, sheetName, logicalPageBox, getStyleFileUrl(), null);
    }
    else
    {
      writeCompleteHeader(docWriter, sheetName, logicalPageBox, null, getStyleManager());
    }

    // no need to check for IOExceptions here, as we know the implementation does not create such things
    final MemoryStringReader stringReader = writer.getBufferWriter().createReader();
    docWriter.writeStream(stringReader);
    stringReader.close();

    docWriter.writeCloseTag(); // for the html ..
    docWriter.close();
  }
View Full Code Here

  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;
  }
View Full Code Here

  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;
  }
View Full Code Here

  }

  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;
View Full Code Here

    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);
  }
View Full Code Here

   * @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();
  }
View Full Code Here

   * @throws java.io.IOException if there is an I/O problem.
   */
  public void write()
      throws IOException, ReportWriterException
  {
    final XmlWriter xmlWriter = getXmlWriter();
    xmlWriter.writeTag(ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.REPORT_CONFIG_TAG, XmlWriterSupport.OPEN);

    final AbstractReportDefinition report = getReport();
    if (report instanceof MasterReport)
    {
      final MasterReport masterReport = (MasterReport) report;
      final DataFactoryWriter writer = new DataFactoryWriter(getReportWriter(), getXmlWriter());
      writer.write();

      writePageDefinition();
      writeReportConfig(masterReport.getConfiguration());
    }

    xmlWriter.writeCloseTag();
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.xmlns.writer.XmlWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.