public class JRXmlExporter extends JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,WriterExporterOutput,JRXmlExporterContext>
JasperPrint
object, but in XML format, instead
of a serialized class. As report templates are defined using the
special XML syntax JRXML, the JasperReports library also has a special XML structure
for storing generated documents in XML format. This format is called JRPXML because
the files produced by the JRXmlExporter usually have the *.jrpxml
extension.
Such XML files can be parsed back into
JasperPrint
object using the JRPrintXmlLoader
utility class.
Their structure is validated against an internal XSD file called jasperprint.xsd
,
that provides the details of the JRPXML structure. Valid JRPXML files
should point to the internal XSD file using a public location, as follows:
<?xml version="1.0" encoding="UTF-8"?> <jasperPrint xmlns="http://jasperreports.sourceforge.net/jasperreports/print" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/print http://jasperreports.sourceforge.net/xsd/jasperprint.xsd" ...>The root element of a JRPXML document is
<jasperPrint>
, which contains a list of
report custom properties (<property>
tags), a list of element origins
(<origin>
tags), a list of
report style definitions (<style>
tags) that are reused by report elements throughout
the document, and a list of pages (<page>
tags), each of which contains a nested list of
elements like lines, rectangles, ellipses, images, and texts.
The quality of this exporter is equal to the Graphics2D
exporter because it preserves
100% of the initial document content and properties. There is no loss in document
quality when exporting to XML because the resulting XML content can be loaded back
into a JasperPrint
object that will look the same as the original one.
The built-in viewers can display documents exported in JRPXML format because they
actually rely on the JRPrintXmlLoader
to load the
document back into a JasperPrint
object before
rendering it on the screen.
_files
suffix, the same directory as the JRPXML file.isEmbeddingImages()
exporter output flag,
which expects a java.lang.Boolean
. By default, the images are embedded in the
resulting XML.JasperPrint
,
JRPrintXmlLoader
Modifier and Type | Class and Description |
---|---|
protected class |
JRXmlExporter.ExporterContext |
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.PageRange
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DEFAULT_OBJECT_TYPE |
protected java.io.File |
destFile |
static java.lang.String |
EXCEPTION_MESSAGE_KEY_EMBEDDING_IMAGE_ERROR |
static java.lang.String |
EXCEPTION_MESSAGE_KEY_IMAGE_WRITE_ERROR |
static java.lang.String |
EXCEPTION_MESSAGE_KEY_REPORT_STYLE_NOT_FOUND |
protected static java.lang.String |
IMAGE_PREFIX |
protected java.io.File |
imagesDir |
protected boolean |
isEmbeddingImages |
static XmlNamespace |
JASPERPRINT_NAMESPACE |
static java.lang.String |
PROPERTY_REPLACE_INVALID_CHARS
Stores the text sequence used to replace invalid XML characters
|
protected java.util.Map<Renderable,java.lang.String> |
rendererToImagePathMap |
protected java.util.Map<java.lang.String,JRStyle> |
stylesMap |
protected java.lang.String |
version |
protected VersionComparator |
versionComparator |
static java.lang.String |
XML_EXPORTER_KEY
The exporter key, as used in
GenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String) . |
protected JRXmlWriteHelper |
xmlWriter |
allSelector, crtCompositeConfiguration, crtCompositeItemConfiguration, crtItem, dateFormatCache, EXCEPTION_MESSAGE_KEY_END_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_INVALID_IMAGE_NAME, EXCEPTION_MESSAGE_KEY_INVALID_ZOOM_RATIO, EXCEPTION_MESSAGE_KEY_MIXED_CALLS_NOT_ALLOWED, EXCEPTION_MESSAGE_KEY_OUTPUT_WRITER_ERROR, EXCEPTION_MESSAGE_KEY_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_START_PAGE_INDEX_OUT_OF_RANGE, exporterConfiguration, exporterContext, exporterInput, exporterOutput, filter, itemConfiguration, jasperPrint, jasperReportsContext, noBackcolorSelector, noneSelector, numberFormatCache, parameters, propertiesUtil, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, styledTextUtil, textValueClasses
Constructor and Description |
---|
JRXmlExporter() |
JRXmlExporter(JasperReportsContext jasperReportsContext) |
Modifier and Type | Method and Description |
---|---|
protected void |
ensureOutput() |
protected void |
exportBookmark(PrintBookmark bookmark) |
protected void |
exportBookmarks(java.util.List<PrintBookmark> bookmarks) |
void |
exportElement(JRPrintElement element) |
protected void |
exportElements(java.util.Collection<JRPrintElement> elements) |
protected void |
exportEllipse(JRPrintEllipse ellipse) |
protected void |
exportFont(JRFont font) |
protected void |
exportFrame(JRPrintFrame frame) |
protected void |
exportGenericElement(JRGenericPrintElement element) |
protected void |
exportGraphicElement(JRPrintGraphicElement element) |
protected void |
exportHyperlinkParameter(JRPrintHyperlinkParameter parameter) |
protected void |
exportHyperlinkParameters(JRPrintHyperlink hyperlink) |
void |
exportImage(JRPrintImage image) |
protected void |
exportLine(JRPrintLine line) |
protected void |
exportOrigin(JROrigin origin) |
protected void |
exportPage(JRPrintPage page) |
protected void |
exportPart(java.lang.Integer pageIndex,
PrintPart part) |
protected void |
exportPen(JRPen pen) |
protected void |
exportPen(java.lang.String element,
JRPen pen) |
protected void |
exportProperties(JRPropertiesHolder propertiesHolder) |
protected void |
exportRectangle(JRPrintRectangle rectangle) |
void |
exportReport()
Performs the export.
|
protected void |
exportReportElement(JRPrintElement element) |
protected void |
exportReportToStream(java.io.Writer writer) |
protected void |
exportStyle(JRStyle style) |
void |
exportTabStop(TabStop tabStop) |
void |
exportText(JRPrintText text) |
protected java.lang.StringBuffer |
formatTextLineBreakOffsets(short[] lineBreakOffsets) |
protected java.lang.Class<ExporterConfiguration> |
getConfigurationInterface() |
java.lang.String |
getExporterKey() |
java.lang.String |
getExporterPropertiesPrefix()
Returns the properties prefix for the current exporter.
|
protected java.lang.Class<ReportExportConfiguration> |
getItemConfigurationInterface() |
protected XmlNamespace |
getNamespace() |
JRXmlWriteHelper |
getXmlWriteHelper()
Returns the XML write helper used by this exporter.
|
protected void |
initExport() |
protected void |
initReport() |
protected boolean |
isNewerVersionOrEqual(java.lang.String oldVersion) |
createFilter, defaultParseNumber, ensureInput, ensureJasperReportsContext, getBooleanCellValue, getCurrentConfiguration, getCurrentItemConfiguration, getCurrentJasperPrint, getCustomHandler, getDateCellValue, getDateFormat, getExporterContext, getExporterInput, getExporterOutput, getHyperlinkProducer, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getPageRange, getParameter, getParameters, getPropertiesUtil, getReportContext, getStyledText, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setJasperPrint, setJasperReportsContext, setOffset, setOffset, setParameter, setParameters, setReportContext
public static final java.lang.String EXCEPTION_MESSAGE_KEY_EMBEDDING_IMAGE_ERROR
public static final java.lang.String EXCEPTION_MESSAGE_KEY_IMAGE_WRITE_ERROR
public static final java.lang.String EXCEPTION_MESSAGE_KEY_REPORT_STYLE_NOT_FOUND
public static final java.lang.String XML_EXPORTER_KEY
GenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String)
.public static final java.lang.String PROPERTY_REPLACE_INVALID_CHARS
protected static final java.lang.String DEFAULT_OBJECT_TYPE
protected static final java.lang.String IMAGE_PREFIX
public static final XmlNamespace JASPERPRINT_NAMESPACE
protected JRXmlWriteHelper xmlWriter
protected java.lang.String version
protected VersionComparator versionComparator
protected java.util.Map<Renderable,java.lang.String> rendererToImagePathMap
protected java.util.Map<java.lang.String,JRStyle> stylesMap
protected boolean isEmbeddingImages
protected java.io.File destFile
protected java.io.File imagesDir
public JRXmlExporter()
JRXmlExporter(JasperReportsContext)
public JRXmlExporter(JasperReportsContext jasperReportsContext)
protected java.lang.Class<ExporterConfiguration> getConfigurationInterface()
protected java.lang.Class<ReportExportConfiguration> getItemConfigurationInterface()
protected void ensureOutput()
ensureOutput
in class JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,WriterExporterOutput,JRXmlExporterContext>
public void exportReport() throws JRException
Exporter
exportReport
in interface Exporter<ExporterInput,ReportExportConfiguration,ExporterConfiguration,WriterExporterOutput>
exportReport
in class JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,WriterExporterOutput,JRXmlExporterContext>
JRException
protected void initExport()
protected void initReport()
protected XmlNamespace getNamespace()
protected void exportReportToStream(java.io.Writer writer) throws JRException, java.io.IOException
JRException
java.io.IOException
protected void exportProperties(JRPropertiesHolder propertiesHolder) throws java.io.IOException
java.io.IOException
protected void exportStyle(JRStyle style) throws java.io.IOException
java.io.IOException
protected void exportOrigin(JROrigin origin) throws java.io.IOException
java.io.IOException
protected void exportBookmarks(java.util.List<PrintBookmark> bookmarks) throws java.io.IOException
java.io.IOException
protected void exportBookmark(PrintBookmark bookmark) throws java.io.IOException
java.io.IOException
protected void exportPart(java.lang.Integer pageIndex, PrintPart part) throws JRException, java.io.IOException
JRException
java.io.IOException
protected void exportPage(JRPrintPage page) throws JRException, java.io.IOException
java.io.IOException
JRException
protected void exportElements(java.util.Collection<JRPrintElement> elements) throws java.io.IOException, JRException
java.io.IOException
JRException
public void exportElement(JRPrintElement element) throws java.io.IOException, JRException
java.io.IOException
JRException
protected void exportLine(JRPrintLine line) throws java.io.IOException
java.io.IOException
protected void exportReportElement(JRPrintElement element) throws java.io.IOException
java.io.IOException
protected void exportGraphicElement(JRPrintGraphicElement element) throws java.io.IOException
java.io.IOException
protected void exportPen(JRPen pen) throws java.io.IOException
java.io.IOException
protected void exportPen(java.lang.String element, JRPen pen) throws java.io.IOException
java.io.IOException
protected void exportRectangle(JRPrintRectangle rectangle) throws java.io.IOException
java.io.IOException
protected void exportEllipse(JRPrintEllipse ellipse) throws java.io.IOException
java.io.IOException
public void exportImage(JRPrintImage image) throws JRException, java.io.IOException
JRException
java.io.IOException
public void exportText(JRPrintText text) throws java.io.IOException
java.io.IOException
protected java.lang.StringBuffer formatTextLineBreakOffsets(short[] lineBreakOffsets)
public void exportTabStop(TabStop tabStop) throws java.io.IOException
java.io.IOException
protected void exportFont(JRFont font) throws java.io.IOException
java.io.IOException
protected void exportFrame(JRPrintFrame frame) throws java.io.IOException, JRException
java.io.IOException
JRException
protected void exportHyperlinkParameters(JRPrintHyperlink hyperlink) throws java.io.IOException
java.io.IOException
protected void exportHyperlinkParameter(JRPrintHyperlinkParameter parameter) throws java.io.IOException
java.io.IOException
protected void exportGenericElement(JRGenericPrintElement element) throws java.io.IOException
java.io.IOException
public java.lang.String getExporterPropertiesPrefix()
JRAbstractExporter
getExporterPropertiesPrefix
in class JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,WriterExporterOutput,JRXmlExporterContext>
public java.lang.String getExporterKey()
public JRXmlWriteHelper getXmlWriteHelper()
protected boolean isNewerVersionOrEqual(java.lang.String oldVersion)
© 2001-2014 TIBCO Software Inc. www.jaspersoft.com