public class JRXmlExporter extends JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,XmlExporterOutput,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 String |
DEFAULT_OBJECT_TYPE |
static String |
EXCEPTION_MESSAGE_KEY_EMBEDDING_IMAGE_ERROR |
static String |
EXCEPTION_MESSAGE_KEY_REPORT_STYLE_NOT_FOUND |
protected static String |
IMAGE_PREFIX |
protected boolean |
isEmbeddingImages |
static XmlNamespace |
JASPERPRINT_NAMESPACE |
static String |
PROPERTY_REPLACE_INVALID_CHARS
Stores the text sequence used to replace invalid XML characters
|
protected RenderersCache |
renderersCache |
protected Map<String,String> |
rendererToImagePathMap |
protected Map<String,JRStyle> |
stylesMap |
protected String |
version |
protected VersionComparator |
versionComparator |
static 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, fontUtil, itemConfiguration, jasperPrint, jasperReportsContext, noBackcolorSelector, noneSelector, numberFormatCache, parameters, propertiesUtil, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, rendererUtil, styledTextUtil, textValueClasses| Constructor and Description |
|---|
JRXmlExporter() |
JRXmlExporter(JasperReportsContext jasperReportsContext) |
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, getRendererUtil, 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, setReportContextpublic static final String EXCEPTION_MESSAGE_KEY_EMBEDDING_IMAGE_ERROR
public static final String EXCEPTION_MESSAGE_KEY_REPORT_STYLE_NOT_FOUND
public static final String XML_EXPORTER_KEY
GenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).public static final String PROPERTY_REPLACE_INVALID_CHARS
protected static final String DEFAULT_OBJECT_TYPE
protected static final String IMAGE_PREFIX
public static final XmlNamespace JASPERPRINT_NAMESPACE
protected JRXmlWriteHelper xmlWriter
protected String version
protected VersionComparator versionComparator
protected RenderersCache renderersCache
protected boolean isEmbeddingImages
public JRXmlExporter()
JRXmlExporter(JasperReportsContext)public JRXmlExporter(JasperReportsContext jasperReportsContext)
protected Class<ExporterConfiguration> getConfigurationInterface()
protected Class<ReportExportConfiguration> getItemConfigurationInterface()
protected void ensureOutput()
ensureOutput in class JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,XmlExporterOutput,JRXmlExporterContext>public void exportReport()
throws JRException
ExporterexportReport in interface Exporter<ExporterInput,ReportExportConfiguration,ExporterConfiguration,XmlExporterOutput>exportReport in class JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,XmlExporterOutput,JRXmlExporterContext>JRExceptionprotected void initExport()
protected void initReport()
protected XmlNamespace getNamespace()
protected void exportReportToStream(Writer writer) throws JRException, IOException
JRExceptionIOExceptionprotected void exportProperties(JRPropertiesHolder propertiesHolder) throws IOException
IOExceptionprotected void exportStyle(JRStyle style) throws IOException
IOExceptionprotected void exportOrigin(JROrigin origin) throws IOException
IOExceptionprotected void exportBookmarks(List<PrintBookmark> bookmarks) throws IOException
IOExceptionprotected void exportBookmark(PrintBookmark bookmark) throws IOException
IOExceptionprotected void exportPart(Integer pageIndex, PrintPart part) throws JRException, IOException
JRExceptionIOExceptionprotected void exportPage(JRPrintPage page) throws JRException, IOException
IOExceptionJRExceptionprotected void exportElements(Collection<JRPrintElement> elements) throws IOException, JRException
IOExceptionJRExceptionpublic void exportElement(JRPrintElement element) throws IOException, JRException
IOExceptionJRExceptionprotected void exportLine(JRPrintLine line) throws IOException
IOExceptionprotected void exportReportElement(JRPrintElement element) throws IOException
IOExceptionprotected void exportGraphicElement(JRPrintGraphicElement element) throws IOException
IOExceptionprotected void exportPen(JRPen pen) throws IOException
IOExceptionprotected void exportPen(String element, JRPen pen) throws IOException
IOExceptionprotected void exportRectangle(JRPrintRectangle rectangle) throws IOException
IOExceptionprotected void exportEllipse(JRPrintEllipse ellipse) throws IOException
IOExceptionpublic void exportImage(JRPrintImage image) throws JRException, IOException
JRExceptionIOExceptionpublic void exportText(JRPrintText text) throws IOException
IOExceptionprotected StringBuilder formatTextLineBreakOffsets(short[] lineBreakOffsets)
public void exportTabStop(TabStop tabStop) throws IOException
IOExceptionprotected void exportFont(JRFont font) throws IOException
IOExceptionprotected void exportFrame(JRPrintFrame frame) throws IOException, JRException
IOExceptionJRExceptionprotected void exportHyperlinkParameters(JRPrintHyperlink hyperlink) throws IOException
IOExceptionprotected void exportHyperlinkParameter(JRPrintHyperlinkParameter parameter) throws IOException
IOExceptionprotected void exportGenericElement(JRGenericPrintElement element) throws IOException
IOExceptionpublic String getExporterPropertiesPrefix()
JRAbstractExportergetExporterPropertiesPrefix in class JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,XmlExporterOutput,JRXmlExporterContext>public String getExporterKey()
getExporterKey in class JRAbstractExporter<ReportExportConfiguration,ExporterConfiguration,XmlExporterOutput,JRXmlExporterContext>public JRXmlWriteHelper getXmlWriteHelper()
protected boolean isNewerVersionOrEqual(String oldVersion)
protected boolean isOlderVersionThan(String version)
Copyright © 2017. All rights reserved.