Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Error in XML page source
Error in XML page source [message #247193] Tue, 10 July 2007 14:08 Go to next message
Eclipse UserFriend
Originally posted by: kale.anuradha.gmail.com

Hi,
I am new to BIRT reports...
I have written a sample program to create sample2.rptdesign Using BIRT
Design APIs. But I get an error "Error in XML Source page" if I try to open
the output file sample2.rptdesign.
Please help..

// Java program which creates sample2.rptdesign using BIRT Design APIs.
/*********************************************************** ********************
* Copyright (c) 2005 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - created
************************************************************ *******************/import java.io.IOException;import org.eclipse.birt.core.framework.Platform;import org.eclipse.birt.report.model.api.CellHandle;import org.eclipse.birt.report.model.api.DesignConfig;import org.eclipse.birt.report.model.api.DesignElementHandle;import org.eclipse.birt.report.model.api.DesignEngine;import org.eclipse.birt.report.model.api.ElementFactory;import org.eclipse.birt.report.model.api.GridHandle;import org.eclipse.birt.report.model.api.IDesignEngine;import org.eclipse.birt.report.model.api.IDesignEngineFactory;impor t org.eclipse.birt.report.model.api.ImageHandle;import org.eclipse.birt.report.model.api.LabelHandle;import org.eclipse.birt.report.model.api.ReportDesignHandle;import org.eclipse.birt.report.model.api.RowHandle;import org.eclipse.birt.report.model.api.SessionHandle;import org.eclipse.birt.report.model.api.activity.SemanticException ;import com.ibm.icu.util.ULocale;/** * Simple BIRT Design Engine API (DEAPI) demo. */public class ReportDesignDemo{ public static void main( String[] args ) { try { buildReport( ); } catch ( IOException e ) { // TODO Auto-generated catch block e.printStackTrace(); } catch ( SemanticException e ) { // TODO Auto-generated catch block e.printStackTrace(); } } // This function shows how to build a very simple BIRT report with a // minimal set of content: a simple grid with an image and a label. static void buildReport( ) throws IOException, SemanticException { // Create a session handle. This is used to manage all open designs. // Your app need create the session only once. //Configure the Engine and start the Platform DesignConfig config = new DesignConfig( ); config.setProperty("BIRT_HOME","C:/birt-runtime-2_2_0/birt-runtime-2_2_0/ReportEngine "); IDesignEngine engine = null; try{ Platform.startup( config ); IDesignEngineFactory factory = (IDesignEngineFactory) Platform .createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_E NGINE_FACTORY ); engine = factory.createDesignEngine( config ); }catch( Exception ex){ ex.printStackTrace(); } SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ; // Create a new report design. ReportDesignHandle design = session.createDesign( ); // The element factory creates instances of the various BIRT elements. ElementFactory factory = design.getElementFactory( ); // Create a simple master page that describes how the report will // appear when printed. // // Note: The report will fail to load in the BIRT designer // unless you create a master page. DesignElementHandle element = factory.newSimpleMasterPage( "PageMaster" ); //$NON-NLS-1$ design.getMasterPages( ).add( element ); // Create a grid and add it to the "body" slot of the report // design. GridHandle grid = factory.newGridItem( null, 2 /* cols */, 1 /* row */ ); design.getBody( ).add( grid ); // Note: Set the table width to 100% to prevent the label // from appearing too narrow in the layout view. grid.setWidth( "100%" ); //$NON-NLS-1$ // Get the first row. RowHandle row = (RowHandle) grid.getRows( ).get( 0 ); // Create an image and add it to the first cell. //ImageHandle image = factory.newImage( null ); CellHandle cell = (CellHandle) row.getCells( ).get( 0 ); //cell.getContent( ).add( image ); //image.setURL("\" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg\"" ); //image.setURL(" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg" ); // Create a label and add it to the second cell. LabelHandle label = factory.newLabel( null ); //cell = (CellHandle) row.getCells( ).get( 1 ); cell.getContent( ).add( label ); label.setText( "Hello, world!" ); //$NON-NLS-1$ // Save the design and close it. design.saveAs( "c:/tmp/sample2.rptdesign" ); //$NON-NLS-1$ design.close( ); System.out.println("Finished"); // We're done! }}//Sample2.rptdesign File<?xml version="1.0" encoding="UTF-8"?><report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.14"id="1"> <styles> <style name="crosstab" id="2"> <property name="borderBottomColor">#CCCCCC</property> <property name="borderBottomStyle">solid</property> <property name="borderBottomWidth">1pt</property> <property name="borderLeftColor">#CCCCCC</property> <property name="borderLeftStyle">solid</property> <property name="borderLeftWidth">1pt</property> <property name="borderRightColor">#CCCCCC</property> <property name="borderRightStyle">solid</property> <property name="borderRightWidth">1pt</property> <property name="borderTopColor">#CCCCCC</property> <property name="borderTopStyle">solid</property> <property name="borderTopWidth">1pt</property> </style> <style name="crosstab-cell" id="3"> <property name="borderBottomColor">#CCCCCC</property> <property name="borderBottomStyle">solid</property> <property name="borderBottomWidth">1pt</property> <property name="borderLeftColor">#CCCCCC</property> <property name="borderLeftStyle">solid</property> <property name="borderLeftWidth">1pt</property> <property name="borderRightColor">#CCCCCC</property> <property name="borderRightStyle">solid</property> <property name="borderRightWidth">1pt</property> <property name="borderTopColor">#CCCCCC</property> <property name="borderTopStyle">solid</property> <property name="borderTopWidth">1pt</property> </style> </styles> <page-setup> <simple-master-page name="Page Master" id="4"/> </page-setup> <body> <grid id="5"> <property name="width">100%</property> <column id="6"/> <column id="7"/> <row id="8"> <cell id="9"> <label id="11"> <text-property name="text">Hello,world!</text-property> </label> </cell> <cell id="10"/> </row> </grid> </body></report>
Re: Error in XML page source [message #247208 is a reply to message #247193] Tue, 10 July 2007 14:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kale.anuradha.gmail.com

Hi,
I am attaching the two files since the following text is not formatted
well...

Regards,
Anuradha.

"Anuradha" <kale.anuradha@gmail.com> wrote in message
news:f700b2$in2$1@build.eclipse.org...
>
> Hi,
> I am new to BIRT reports...
> I have written a sample program to create sample2.rptdesign Using BIRT
> Design APIs. But I get an error "Error in XML Source page" if I try to
> open
> the output file sample2.rptdesign.
> Please help..
>
> // Java program which creates sample2.rptdesign using BIRT Design APIs.
> /*********************************************************** ********************
> * Copyright (c) 2005 Actuate Corporation.
> * All rights reserved. This program and the accompanying materials
> * are made available under the terms of the Eclipse Public License v1.0
> * which accompanies this distribution, and is available at
> * http://www.eclipse.org/legal/epl-v10.html
> *
> * Contributors:
> * Actuate Corporation - created
> ************************************************************ *******************/import
> java.io.IOException;import org.eclipse.birt.core.framework.Platform;import
> org.eclipse.birt.report.model.api.CellHandle;import
> org.eclipse.birt.report.model.api.DesignConfig;import
> org.eclipse.birt.report.model.api.DesignElementHandle;import
> org.eclipse.birt.report.model.api.DesignEngine;import
> org.eclipse.birt.report.model.api.ElementFactory;import
> org.eclipse.birt.report.model.api.GridHandle;import
> org.eclipse.birt.report.model.api.IDesignEngine;import
> org.eclipse.birt.report.model.api.IDesignEngineFactory;impor t
> org.eclipse.birt.report.model.api.ImageHandle;import
> org.eclipse.birt.report.model.api.LabelHandle;import
> org.eclipse.birt.report.model.api.ReportDesignHandle;import
> org.eclipse.birt.report.model.api.RowHandle;import
> org.eclipse.birt.report.model.api.SessionHandle;import
> org.eclipse.birt.report.model.api.activity.SemanticException ;import
> com.ibm.icu.util.ULocale;/** * Simple BIRT Design Engine API (DEAPI) demo.
> */public class ReportDesignDemo{ public static void main( String[] args )
> { try { buildReport( ); } catch ( IOException e ) { // TODO
> Auto-generated catch block e.printStackTrace(); } catch (
> SemanticException e ) { // TODO Auto-generated catch block
> e.printStackTrace(); } } // This function shows how to build a very
> simple BIRT report with a // minimal set of content: a simple grid with an
> image and a label. static void buildReport( ) throws IOException,
> SemanticException { // Create a session handle. This is used to manage
> all open designs. // Your app need create the session only once.
> //Configure the Engine and start the Platform DesignConfig config = new
> DesignConfig( );
> config.setProperty("BIRT_HOME","C:/birt-runtime-2_2_0/birt-runtime-2_2_0/ReportEngine ");
> IDesignEngine engine = null; try{ Platform.startup( config );
> IDesignEngineFactory factory = (IDesignEngineFactory) Platform
> .createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_E NGINE_FACTORY
> ); engine = factory.createDesignEngine( config ); }catch( Exception
> ex){ ex.printStackTrace(); } SessionHandle session =
> engine.newSessionHandle( ULocale.ENGLISH ) ; // Create a new report
> design. ReportDesignHandle design = session.createDesign( ); // The
> element factory creates instances of the various BIRT elements.
> ElementFactory factory = design.getElementFactory( ); // Create a simple
> master page that describes how the report will // appear when printed.
> // // Note: The report will fail to load in the BIRT designer // unless
> you create a master page. DesignElementHandle element =
> factory.newSimpleMasterPage( "PageMaster" ); //$NON-NLS-1$
> design.getMasterPages( ).add( element ); // Create a grid and add it to
> the "body" slot of the report // design. GridHandle grid =
> factory.newGridItem( null, 2 /* cols */, 1 /* row */ );
> design.getBody( ).add( grid ); // Note: Set the table width to 100% to
> prevent the label // from appearing too narrow in the layout view.
> grid.setWidth( "100%" ); //$NON-NLS-1$ // Get the first row. RowHandle
> row = (RowHandle) grid.getRows( ).get( 0 ); // Create an image and add it
> to the first cell. //ImageHandle image = factory.newImage( null );
> CellHandle cell = (CellHandle) row.getCells( ).get( 0 );
> //cell.getContent( ).add( image );
> //image.setURL("\" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg\""
> );
> //image.setURL(" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg"
> ); // Create a label and add it to the second cell. LabelHandle label =
> factory.newLabel( null ); //cell = (CellHandle) row.getCells( ).get( 1 );
> cell.getContent( ).add( label ); label.setText( "Hello, world!" );
> //$NON-NLS-1$ // Save the design and close it. design.saveAs(
> "c:/tmp/sample2.rptdesign" ); //$NON-NLS-1$ design.close( );
> System.out.println("Finished"); // We're done! }}//Sample2.rptdesign
> File<?xml version="1.0" encoding="UTF-8"?><report
> xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.14"id="1">
> <styles> <style name="crosstab" id="2"> <property
> name="borderBottomColor">#CCCCCC</property> <property
> name="borderBottomStyle">solid</property> <property
> name="borderBottomWidth">1pt</property> <property
> name="borderLeftColor">#CCCCCC</property> <property
> name="borderLeftStyle">solid</property> <property
> name="borderLeftWidth">1pt</property> <property
> name="borderRightColor">#CCCCCC</property> <property
> name="borderRightStyle">solid</property> <property
> name="borderRightWidth">1pt</property> <property
> name="borderTopColor">#CCCCCC</property> <property
> name="borderTopStyle">solid</property> <property
> name="borderTopWidth">1pt</property> </style> <style
> name="crosstab-cell" id="3"> <property
> name="borderBottomColor">#CCCCCC</property> <property
> name="borderBottomStyle">solid</property> <property
> name="borderBottomWidth">1pt</property> <property
> name="borderLeftColor">#CCCCCC</property> <property
> name="borderLeftStyle">solid</property> <property
> name="borderLeftWidth">1pt</property> <property
> name="borderRightColor">#CCCCCC</property> <property
> name="borderRightStyle">solid</property> <property
> name="borderRightWidth">1pt</property> <property
> name="borderTopColor">#CCCCCC</property> <property
> name="borderTopStyle">solid</property> <property
> name="borderTopWidth">1pt</property> </style> </styles>
> <page-setup> <simple-master-page name="Page Master" id="4"/>
> </page-setup> <body> <grid id="5"> <property
> name="width">100%</property> <column id="6"/>
> <column id="7"/> <row id="8"> <cell id="9">
> <label id="11"> <text-property
> name="text">Hello,world!</text-property> </label>
> </cell> <cell id="10"/> </row> </grid>
> </body></report>
>



Re: Error in XML page source [message #247298 is a reply to message #247208] Wed, 11 July 2007 00:50 Go to previous messageGo to next message
Wang Qiangsheng is currently offline Wang QiangshengFriend
Messages: 76
Registered: July 2009
Member
Anuradha wrote:
> Hi,
> I am attaching the two files since the following text is not formatted
> well...
>
> Regards,
> Anuradha.
>
> "Anuradha" <kale.anuradha@gmail.com> wrote in message
> news:f700b2$in2$1@build.eclipse.org...
>> Hi,
>> I am new to BIRT reports...
>> I have written a sample program to create sample2.rptdesign Using BIRT
>> Design APIs. But I get an error "Error in XML Source page" if I try to
>> open
>> the output file sample2.rptdesign.
>> Please help..
>>
>> // Java program which creates sample2.rptdesign using BIRT Design APIs.
>> /*********************************************************** ********************
>> * Copyright (c) 2005 Actuate Corporation.
>> * All rights reserved. This program and the accompanying materials
>> * are made available under the terms of the Eclipse Public License v1.0
>> * which accompanies this distribution, and is available at
>> * http://www.eclipse.org/legal/epl-v10.html
>> *
>> * Contributors:
>> * Actuate Corporation - created
>> ************************************************************ *******************/import
>> java.io.IOException;import org.eclipse.birt.core.framework.Platform;import
>> org.eclipse.birt.report.model.api.CellHandle;import
>> org.eclipse.birt.report.model.api.DesignConfig;import
>> org.eclipse.birt.report.model.api.DesignElementHandle;import
>> org.eclipse.birt.report.model.api.DesignEngine;import
>> org.eclipse.birt.report.model.api.ElementFactory;import
>> org.eclipse.birt.report.model.api.GridHandle;import
>> org.eclipse.birt.report.model.api.IDesignEngine;import
>> org.eclipse.birt.report.model.api.IDesignEngineFactory;impor t
>> org.eclipse.birt.report.model.api.ImageHandle;import
>> org.eclipse.birt.report.model.api.LabelHandle;import
>> org.eclipse.birt.report.model.api.ReportDesignHandle;import
>> org.eclipse.birt.report.model.api.RowHandle;import
>> org.eclipse.birt.report.model.api.SessionHandle;import
>> org.eclipse.birt.report.model.api.activity.SemanticException ;import
>> com.ibm.icu.util.ULocale;/** * Simple BIRT Design Engine API (DEAPI) demo.
>> */public class ReportDesignDemo{ public static void main( String[] args )
>> { try { buildReport( ); } catch ( IOException e ) { // TODO
>> Auto-generated catch block e.printStackTrace(); } catch (
>> SemanticException e ) { // TODO Auto-generated catch block
>> e.printStackTrace(); } } // This function shows how to build a very
>> simple BIRT report with a // minimal set of content: a simple grid with an
>> image and a label. static void buildReport( ) throws IOException,
>> SemanticException { // Create a session handle. This is used to manage
>> all open designs. // Your app need create the session only once.
>> //Configure the Engine and start the Platform DesignConfig config = new
>> DesignConfig( );
>> config.setProperty("BIRT_HOME","C:/birt-runtime-2_2_0/birt-runtime-2_2_0/ReportEngine ");
>> IDesignEngine engine = null; try{ Platform.startup( config );
>> IDesignEngineFactory factory = (IDesignEngineFactory) Platform
>> .createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_E NGINE_FACTORY
>> ); engine = factory.createDesignEngine( config ); }catch( Exception
>> ex){ ex.printStackTrace(); } SessionHandle session =
>> engine.newSessionHandle( ULocale.ENGLISH ) ; // Create a new report
>> design. ReportDesignHandle design = session.createDesign( ); // The
>> element factory creates instances of the various BIRT elements.
>> ElementFactory factory = design.getElementFactory( ); // Create a simple
>> master page that describes how the report will // appear when printed.
>> // // Note: The report will fail to load in the BIRT designer // unless
>> you create a master page. DesignElementHandle element =
>> factory.newSimpleMasterPage( "PageMaster" ); //$NON-NLS-1$
>> design.getMasterPages( ).add( element ); // Create a grid and add it to
>> the "body" slot of the report // design. GridHandle grid =
>> factory.newGridItem( null, 2 /* cols */, 1 /* row */ );
>> design.getBody( ).add( grid ); // Note: Set the table width to 100% to
>> prevent the label // from appearing too narrow in the layout view.
>> grid.setWidth( "100%" ); //$NON-NLS-1$ // Get the first row. RowHandle
>> row = (RowHandle) grid.getRows( ).get( 0 ); // Create an image and add it
>> to the first cell. //ImageHandle image = factory.newImage( null );
>> CellHandle cell = (CellHandle) row.getCells( ).get( 0 );
>> //cell.getContent( ).add( image );
>> //image.setURL("\" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg\""
>> );
>> //image.setURL(" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg"
>> ); // Create a label and add it to the second cell. LabelHandle label =
>> factory.newLabel( null ); //cell = (CellHandle) row.getCells( ).get( 1 );
>> cell.getContent( ).add( label ); label.setText( "Hello, world!" );
>> //$NON-NLS-1$ // Save the design and close it. design.saveAs(
>> "c:/tmp/sample2.rptdesign" ); //$NON-NLS-1$ design.close( );
>> System.out.println("Finished"); // We're done! }}//Sample2.rptdesign
>> File<?xml version="1.0" encoding="UTF-8"?><report
>> xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.14"id="1">
>> <styles> <style name="crosstab" id="2"> <property
>> name="borderBottomColor">#CCCCCC</property> <property
>> name="borderBottomStyle">solid</property> <property
>> name="borderBottomWidth">1pt</property> <property
>> name="borderLeftColor">#CCCCCC</property> <property
>> name="borderLeftStyle">solid</property> <property
>> name="borderLeftWidth">1pt</property> <property
>> name="borderRightColor">#CCCCCC</property> <property
>> name="borderRightStyle">solid</property> <property
>> name="borderRightWidth">1pt</property> <property
>> name="borderTopColor">#CCCCCC</property> <property
>> name="borderTopStyle">solid</property> <property
>> name="borderTopWidth">1pt</property> </style> <style
>> name="crosstab-cell" id="3"> <property
>> name="borderBottomColor">#CCCCCC</property> <property
>> name="borderBottomStyle">solid</property> <property
>> name="borderBottomWidth">1pt</property> <property
>> name="borderLeftColor">#CCCCCC</property> <property
>> name="borderLeftStyle">solid</property> <property
>> name="borderLeftWidth">1pt</property> <property
>> name="borderRightColor">#CCCCCC</property> <property
>> name="borderRightStyle">solid</property> <property
>> name="borderRightWidth">1pt</property> <property
>> name="borderTopColor">#CCCCCC</property> <property
>> name="borderTopStyle">solid</property> <property
>> name="borderTopWidth">1pt</property> </style> </styles>
>> <page-setup> <simple-master-page name="Page Master" id="4"/>
>> </page-setup> <body> <grid id="5"> <property
>> name="width">100%</property> <column id="6"/>
>> <column id="7"/> <row id="8"> <cell id="9">
>> <label id="11"> <text-property
>> name="text">Hello,world!</text-property> </label>
>> </cell> <cell id="10"/> </row> </grid>
>> </body></report>
>>
>
>
I can open the file without any errors.
Please confirm if the report design api's version is the same as the
designer's version.

Cheers
Qs
Re: Error in XML page source [message #247343 is a reply to message #247298] Wed, 11 July 2007 14:06 Go to previous message
Eclipse UserFriend
Originally posted by: kale.anuradha.gmail.com

Hi Qwang,
Thanks for the reply. My BIRT runtime engine version was 2_2_0 and my
BIRT version was 2_1_1.
After using the same version of both my problem is solved now.

Regards,
Anuradha.

"qwang" <qwang@actuate.com> wrote in message
news:f719g1$ktm$1@build.eclipse.org...
> Anuradha wrote:
>> Hi,
>> I am attaching the two files since the following text is not formatted
>> well...
>>
>> Regards,
>> Anuradha.
>>
>> "Anuradha" <kale.anuradha@gmail.com> wrote in message
>> news:f700b2$in2$1@build.eclipse.org...
>>> Hi,
>>> I am new to BIRT reports...
>>> I have written a sample program to create sample2.rptdesign Using BIRT
>>> Design APIs. But I get an error "Error in XML Source page" if I try to
>>> open
>>> the output file sample2.rptdesign.
>>> Please help..
>>>
>>> // Java program which creates sample2.rptdesign using BIRT Design APIs.
>>> /*********************************************************** ********************
>>> * Copyright (c) 2005 Actuate Corporation.
>>> * All rights reserved. This program and the accompanying materials
>>> * are made available under the terms of the Eclipse Public License v1.0
>>> * which accompanies this distribution, and is available at
>>> * http://www.eclipse.org/legal/epl-v10.html
>>> *
>>> * Contributors:
>>> * Actuate Corporation - created
>>> ************************************************************ *******************/import
>>> java.io.IOException;import
>>> org.eclipse.birt.core.framework.Platform;import
>>> org.eclipse.birt.report.model.api.CellHandle;import
>>> org.eclipse.birt.report.model.api.DesignConfig;import
>>> org.eclipse.birt.report.model.api.DesignElementHandle;import
>>> org.eclipse.birt.report.model.api.DesignEngine;import
>>> org.eclipse.birt.report.model.api.ElementFactory;import
>>> org.eclipse.birt.report.model.api.GridHandle;import
>>> org.eclipse.birt.report.model.api.IDesignEngine;import
>>> org.eclipse.birt.report.model.api.IDesignEngineFactory;impor t
>>> org.eclipse.birt.report.model.api.ImageHandle;import
>>> org.eclipse.birt.report.model.api.LabelHandle;import
>>> org.eclipse.birt.report.model.api.ReportDesignHandle;import
>>> org.eclipse.birt.report.model.api.RowHandle;import
>>> org.eclipse.birt.report.model.api.SessionHandle;import
>>> org.eclipse.birt.report.model.api.activity.SemanticException ;import
>>> com.ibm.icu.util.ULocale;/** * Simple BIRT Design Engine API (DEAPI)
>>> demo. */public class ReportDesignDemo{ public static void main( String[]
>>> args ) { try { buildReport( ); } catch ( IOException e ) { //
>>> TODO Auto-generated catch block e.printStackTrace(); } catch (
>>> SemanticException e ) { // TODO Auto-generated catch block
>>> e.printStackTrace(); } } // This function shows how to build a very
>>> simple BIRT report with a // minimal set of content: a simple grid with
>>> an image and a label. static void buildReport( ) throws IOException,
>>> SemanticException { // Create a session handle. This is used to manage
>>> all open designs. // Your app need create the session only once.
>>> //Configure the Engine and start the Platform DesignConfig config = new
>>> DesignConfig( );
>>> config.setProperty("BIRT_HOME","C:/birt-runtime-2_2_0/birt-runtime-2_2_0/ReportEngine ");
>>> IDesignEngine engine = null; try{ Platform.startup( config );
>>> IDesignEngineFactory factory = (IDesignEngineFactory) Platform
>>> .createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_E NGINE_FACTORY
>>> ); engine = factory.createDesignEngine( config ); }catch( Exception
>>> ex){ ex.printStackTrace(); } SessionHandle session =
>>> engine.newSessionHandle( ULocale.ENGLISH ) ; // Create a new report
>>> design. ReportDesignHandle design = session.createDesign( ); // The
>>> element factory creates instances of the various BIRT elements.
>>> ElementFactory factory = design.getElementFactory( ); // Create a
>>> simple master page that describes how the report will // appear when
>>> printed. // // Note: The report will fail to load in the BIRT designer
>>> // unless you create a master page. DesignElementHandle element =
>>> factory.newSimpleMasterPage( "PageMaster" ); //$NON-NLS-1$
>>> design.getMasterPages( ).add( element ); // Create a grid and add it to
>>> the "body" slot of the report // design. GridHandle grid =
>>> factory.newGridItem( null, 2 /* cols */, 1 /* row */ );
>>> design.getBody( ).add( grid ); // Note: Set the table width to 100% to
>>> prevent the label // from appearing too narrow in the layout view.
>>> grid.setWidth( "100%" ); //$NON-NLS-1$ // Get the first row. RowHandle
>>> row = (RowHandle) grid.getRows( ).get( 0 ); // Create an image and add
>>> it to the first cell. //ImageHandle image = factory.newImage( null );
>>> CellHandle cell = (CellHandle) row.getCells( ).get( 0 );
>>> //cell.getContent( ).add( image );
>>> //image.setURL("\" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg\""
>>> );
>>> //image.setURL(" http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip -4.jpg"
>>> ); // Create a label and add it to the second cell. LabelHandle label
>>> = factory.newLabel( null ); //cell = (CellHandle)
>>> row.getCells( ).get( 1 ); cell.getContent( ).add( label );
>>> label.setText( "Hello, world!" ); //$NON-NLS-1$ // Save the design and
>>> close it. design.saveAs( "c:/tmp/sample2.rptdesign" ); //$NON-NLS-1$
>>> design.close( ); System.out.println("Finished"); // We're
>>> done! }}//Sample2.rptdesign File<?xml version="1.0"
>>> encoding="UTF-8"?><report
>>> xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.14"id="1">
>>> <styles> <style name="crosstab" id="2"> <property
>>> name="borderBottomColor">#CCCCCC</property> <property
>>> name="borderBottomStyle">solid</property> <property
>>> name="borderBottomWidth">1pt</property> <property
>>> name="borderLeftColor">#CCCCCC</property> <property
>>> name="borderLeftStyle">solid</property> <property
>>> name="borderLeftWidth">1pt</property> <property
>>> name="borderRightColor">#CCCCCC</property> <property
>>> name="borderRightStyle">solid</property> <property
>>> name="borderRightWidth">1pt</property> <property
>>> name="borderTopColor">#CCCCCC</property> <property
>>> name="borderTopStyle">solid</property> <property
>>> name="borderTopWidth">1pt</property> </style> <style
>>> name="crosstab-cell" id="3"> <property
>>> name="borderBottomColor">#CCCCCC</property> <property
>>> name="borderBottomStyle">solid</property> <property
>>> name="borderBottomWidth">1pt</property> <property
>>> name="borderLeftColor">#CCCCCC</property> <property
>>> name="borderLeftStyle">solid</property> <property
>>> name="borderLeftWidth">1pt</property> <property
>>> name="borderRightColor">#CCCCCC</property> <property
>>> name="borderRightStyle">solid</property> <property
>>> name="borderRightWidth">1pt</property> <property
>>> name="borderTopColor">#CCCCCC</property> <property
>>> name="borderTopStyle">solid</property> <property
>>> name="borderTopWidth">1pt</property> </style> </styles>
>>> <page-setup> <simple-master-page name="Page Master" id="4"/>
>>> </page-setup> <body> <grid id="5"> <property
>>> name="width">100%</property> <column id="6"/> <column
>>> id="7"/> <row id="8"> <cell id="9"> <label
>>> id="11"> <text-property
>>> name="text">Hello,world!</text-property> </label>
>>> </cell> <cell id="10"/> </row> </grid>
>>> </body></report>
>>>
>>
>>
> I can open the file without any errors.
> Please confirm if the report design api's version is the same as the
> designer's version.
>
> Cheers
> Qs
Previous Topic:How to generate a report using command line?
Next Topic:BIRT on Win XP pro
Goto Forum:
  


Current Time: Fri Apr 19 21:09:31 GMT 2024

Powered by FUDForum. Page generated in 0.03031 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top