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

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


    private HtmlRenderingSetup(final MasterReport report)
    {
      this.report = report;
      sw = new StringWriter();
      writer = new XmlWriter(sw, new DefaultTagDescription(), "  ", "\n");
      writer.addImpliedNamespace("http://www.w3.org/1999/xhtml", "");
    }
View Full Code Here


    tagDescription.setDefaultNamespace(ConfigEditorBoot.NAMESPACE);
    tagDescription.setNamespaceHasCData(ConfigEditorBoot.NAMESPACE, false);
    tagDescription.setElementHasCData(ConfigEditorBoot.NAMESPACE, "text", true);
    tagDescription.setElementHasCData(ConfigEditorBoot.NAMESPACE, "description", true);
   
    final XmlWriter dwriter = new XmlWriter(writer, tagDescription);


    dwriter.writeXmlDeclaration(encoding);
    dwriter.writeTag(ConfigEditorBoot.NAMESPACE,
        "config-description", attList, XmlWriterSupport.OPEN); //$NON-NLS-1$

    final CharacterEntityParser parser = CharacterEntityParser.createXMLEntityParser();
    for (int i = 0; i < getSize(); i++)
    {
      final ConfigDescriptionEntry entry = get(i);
      final AttributeList p = new AttributeList();
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "name", entry.getKeyName()); //$NON-NLS-1$
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "global", String.valueOf(entry.isGlobal())); //$NON-NLS-1$
      p.setAttribute(ConfigEditorBoot.NAMESPACE, "hidden", String.valueOf(entry.isHidden())); //$NON-NLS-1$
      dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "key", p, XmlWriterSupport.OPEN); //$NON-NLS-1$
      if (entry.getDescription() != null)
      {
        dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "description", XmlWriterSupport.OPEN); //$NON-NLS-1$
        writer.write(parser.encodeEntities(entry.getDescription()));
        dwriter.writeCloseTag();
      }
      if (entry instanceof ClassConfigDescriptionEntry)
      {
        final ClassConfigDescriptionEntry ce = (ClassConfigDescriptionEntry) entry;
        if (ce.getBaseClass() != null)
        {
          dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "class", "instanceof", //$NON-NLS-1$ //$NON-NLS-2$
              ce.getBaseClass().getName(), XmlWriterSupport.CLOSE);
        }
        else
        {
          dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "class", "instanceof", //$NON-NLS-1$ //$NON-NLS-2$
              "java.lang.Object", XmlWriterSupport.CLOSE); //$NON-NLS-1$
        }
      }
      else if (entry instanceof TextConfigDescriptionEntry)
      {
        dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "text", //$NON-NLS-1$
            new AttributeList(), XmlWriterSupport.CLOSE);
      }
      else if (entry instanceof EnumConfigDescriptionEntry)
      {
        final EnumConfigDescriptionEntry en = (EnumConfigDescriptionEntry) entry;
        dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "enum", XmlWriterSupport.OPEN); //$NON-NLS-1$

        final String[] alts = en.getOptions();
        if (alts != null)
        {
          for (int optCount = 0; optCount < alts.length; optCount++)
          {
            dwriter.writeTag(ConfigEditorBoot.NAMESPACE, "text", XmlWriterSupport.OPEN); //$NON-NLS-1$
            dwriter.writeTextNormalized(alts[optCount], false);
            dwriter.writeCloseTag();
          }
        }
        dwriter.writeCloseTag();
      }
      dwriter.writeCloseTag();
    }
    dwriter.writeCloseTag();
    writer.flush();
  }
View Full Code Here

  public void write(final OutputStream out) throws IOException
  {
    final DefaultTagDescription tagDescription = new DefaultTagDescription();
    tagDescription.configure(LibDocBundleBoot.getInstance().getGlobalConfig(), CONFIG_PREFIX);

    final XmlWriter writer = new XmlWriter
        (new OutputStreamWriter(out, "UTF-8"), tagDescription, "  ", "\n");
    writer.setAlwaysAddNamespace(true);
    writer.setWriteFinalLinebreak(true);

    try
    {

      writer.writeXmlDeclaration("UTF-8");

      final AttributeList rootAttributes = new AttributeList();
      rootAttributes.addNamespaceDeclaration("manifest", NAMESPACE);
      writer.writeTag(NAMESPACE, "manifest", rootAttributes, XmlWriterSupport.OPEN);

      final String[] entries = bundleManifest.getEntries();
      Arrays.sort(entries);

      final int length = entries.length;
      for (int i = 0; i < length; i++)
      {
        final String fullPath = entries[i];
        final String mediaType = bundleManifest.getMimeType(fullPath);
        if (mediaType == null)
        {
          continue;
        }

        final AttributeList entryAttrs = new AttributeList();
        final String[] attributeNames = bundleManifest.getAttributeNames(fullPath);

        for (int j = 0; j < attributeNames.length; j++)
        {
          final String attributeName = attributeNames[j];
          final String attr = bundleManifest.getAttribute(fullPath, attributeName);
          if (attr != null)
          {
            entryAttrs.setAttribute(NAMESPACE, attributeName, attr);
          }
        }
        entryAttrs.setAttribute(NAMESPACE, "full-path", fullPath);
        entryAttrs.setAttribute(NAMESPACE, "media-type", mediaType);
        writer.writeTag(NAMESPACE, "file-entry", entryAttrs, XmlWriterSupport.CLOSE);
      }

      writer.writeCloseTag();
    }
    finally
    {
      writer.flush();
    }
  }
View Full Code Here

    }

    final DefaultTagDescription tagDescription = new DefaultTagDescription();
    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);

    try
    {

      writer.writeXmlDeclaration("UTF-8");

      final AttributeList rootAttributes = new AttributeList();
      rootAttributes.addNamespaceDeclaration("office", OFFICE_NAMESPACE);
      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);

      final String[] namespaces = bundleMetaData.getNamespaces();
      final int namspacesLength = namespaces.length;
      for (int namespaceIdx = 0; namespaceIdx < namspacesLength; namespaceIdx++)
      {
        final String namespace = namespaces[namespaceIdx];
        final String[] names = bundleMetaData.getNames(namespace);
        final int namesLength = names.length;
        for (int nameIdx = 0; nameIdx < namesLength; nameIdx++)
        {
          final String name = names[nameIdx];
          final Object value = bundleMetaData.getBundleAttribute(namespace, name);
          if (value == null)
          {
            continue;
          }

          final BundleMetaDataEntryWriteHandler writeHandler = writeHandlerFactory.getHandler(namespace, name);
          if (writeHandler == null)
          {
            continue;
          }

          writeHandler.write(this, writer, namespace, name, value);
        }
      }

      writer.writeCloseTag();
      writer.writeCloseTag();
    }
    finally
    {
      writer.flush();
    }
  }
View Full Code Here

    if (isUseKeyObjectDescription(key, o) == false)
    {
      p.setAttribute(ExtParserModule.NAMESPACE, "class", o.getClass().getName());
    }

    final XmlWriter writer = getXmlWriter();
    final List parameterNames = getParameterNames(od);
    if (isBasicKey(parameterNames, od))
    {
      writer.writeTag(ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.BASIC_KEY_TAG, p, XmlWriterSupport.OPEN);
      writer.writeTextNormalized((String) od.getParameter("value"), false);
      writer.writeCloseTag();
    }
    else
    {
      writer.writeTag(ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.COMPOUND_KEY_TAG, p,
          XmlWriterSupport.OPEN);
      final ObjectWriter objWriter = new ObjectWriter
          (getReportWriter(), o, od, writer);
      objWriter.write();
      writer.writeCloseTag();
    }
  }
View Full Code Here

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

    writeRootBand(ReportDescriptionWriter.REPORT_HEADER_TAG, getReport().getReportHeader());
    writeRootBand(ReportDescriptionWriter.REPORT_FOOTER_TAG, getReport().getReportFooter());
    writeRootBand(ReportDescriptionWriter.PAGE_HEADER_TAG, getReport().getPageHeader());
    writeRootBand(ReportDescriptionWriter.PAGE_FOOTER_TAG, getReport().getPageFooter());
    writeRootBand(ReportDescriptionWriter.WATERMARK_TAG, getReport().getWatermark());
    writeGroups();

    final GroupDataBody dataBody = (GroupDataBody) getReport().getChildElementByType(GroupDataBodyType.INSTANCE);
    if (dataBody != null)
    {
      writeRootBand(ReportDescriptionWriter.ITEMBAND_TAG, dataBody.getItemBand());
      writeRootBand(ReportDescriptionWriter.NO_DATA_BAND_TAG, dataBody.getNoDataBand());
    }

    writer.writeCloseTag();
  }
View Full Code Here

   */
  private void writeBand(final String tagName,
                         final Band band)
      throws IOException, ReportWriterException
  {
    final XmlWriter writer = getXmlWriter();
    if (band.getName().startsWith(Band.ANONYMOUS_BAND_PREFIX) ||
        band.getName().startsWith(Element.ANONYMOUS_ELEMENT_PREFIX))
    {
      writer.writeTag(ExtParserModule.NAMESPACE, tagName, XmlWriterSupport.OPEN);
    }
    else
    {
      writer.writeTag(ExtParserModule.NAMESPACE, tagName,
          "name", band.getName(), XmlWriterSupport.OPEN);
    }

    writeStyleInfo(band);

    final Element[] list = band.getElementArray();
    for (int i = 0; i < list.length; i++)
    {
      if (list[i] instanceof Band)
      {
        final Band b = (Band) list[i];
        writeBand(ReportDescriptionWriter.BAND_TAG, b);
      }
      else
      {
        writeElement(list[i]);
      }
    }

    if (band instanceof RootLevelBand)
    {
      writeSubReports((RootLevelBand) band);
    }

    writer.writeCloseTag();
  }
View Full Code Here

  }

  private void writeStyleInfo(final Element band)
      throws IOException, ReportWriterException
  {
    final XmlWriter writer = getXmlWriter();
    final ElementStyleSheet styleSheet = band.getStyle();
    if (isStyleSheetEmpty(styleSheet) == false)
    {
      writer.writeTag(ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.STYLE_TAG, XmlWriterSupport.OPEN);

      final StyleWriter styleWriter =
          new StyleWriter(getReportWriter(), band.getStyle(), writer);
      styleWriter.write();
      writer.writeCloseTag();
    }


    final Map<StyleKey,Expression> styleExpressions = band.getStyleExpressions();
    if (styleExpressions.isEmpty() == false)
View Full Code Here

    if (element.getName().startsWith(Element.ANONYMOUS_ELEMENT_PREFIX) == false)
    {
      attList.setAttribute(ExtParserModule.NAMESPACE, "name", element.getName());
    }

    final XmlWriter writer = getXmlWriter();
    writer.writeTag(ExtParserModule.NAMESPACE, ReportDescriptionWriter.ELEMENT_TAG, attList, XmlWriterSupport.OPEN);

    writeStyleInfo(element);
    writeDataSourceForElement(element);

    writer.writeCloseTag();
  }
View Full Code Here

    if (dsname == null)
    {
      throw new ReportWriterException("No name for DataSource " + datasource);
    }

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

    final DataSourceWriter dsWriter =
        new DataSourceWriter(reportWriter, datasource, od, writer);
    dsWriter.write();

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