To import an HDS from an XML file, follow the steps below:
JReport Designer supports all kinds of URI as the XML data source. See the detailed information below:
"http://localhost:8888/jrserver%2fSampleReports%2fSampleReports.cat/StockMarket.cls?jrs.cmd=jrs.try_vw&jrs.result_type=7&jrs.param$p_Year=2007&jrs.param$p_Month=2"
It is the URL used to run the sample report StockMarket.cls to the XML format in JReport Server. Type the URL into the XML URI text field, and click the Load Tree button, the structure of the returned XML stream will be loaded in the Structure box (before doing so, make sure that JReport Server is started). Modify the column properties in the Columns box as required.
The colon ':' and '@' symbols are used to identify JReport parameter names. If these symbols are used in your XML URI and you do not want JReport to parse them as parameters, you must add quotation marks to them. For example, when you browse to d:\test\employee.xml
, you can quote it either as "d:\test\employee.xml"
or d":"\test\employee.xml
.
Note that you should check the No Security Checking option in the Advanced panel in the JReport Server Administration > Configuration page before parsing this URL. In addition, JReport parameters can be dynamically referenced in the URI for setting different values at runtime.
Notes:
When you import an XML format HDS with an XSD file, the XML file only provides the data to the JReport Designer reports, while the structure and data type etc. of the data from the XML file is defined in the XSD file. That is, the structure of the HDS is determined by the XSD file. You should be aware of the following points about the XSD file in order to generate a correct report based on an XML format HDS with an XSD file.
Data type conversion table
Before the data type defined in the XSD file can function with JReport Designer, it should first be converted into a corresponding data type when the XML format hierarchical data source is imported, following the rules in the conversion table below.
XML Data Type | JReport Data Type |
---|---|
SchemaSymbols.ATTVAL_BOOLEAN | java.sql.Types.BIT |
SchemaSymbols.ATTVAL_INT | java.sql.Types.INTEGER |
SchemaSymbols.ATTVAL_SHORT | java.sql.Types.SMALLINT |
SchemaSymbols.ATTVAL_BYTE | java.sql.Types.TINYINT |
SchemaSymbols.ATTVAL_INTEGER | java.sql.Types.INTEGER |
SchemaSymbols.ATTVAL_NONPOSITIVEINTEGER | java.sql.Types.INTEGER |
SchemaSymbols.ATTVAL_NEGATIVEINTEGER | java.sql.Types.INTEGER |
SchemaSymbols.ATTVAL_NONNEGATIVEINTEGER | java.sql.Types.INTEGER |
SchemaSymbols.ATTVAL_UNSIGNEDLONG | java.sql.Types.BIGINT |
SchemaSymbols.ATTVAL_LONG | java.sql.Types.BIGINT |
SchemaSymbols.ATTVAL_UNSIGNEDINT, //4294967295 | java.sql.Types.BIGINT |
SchemaSymbols.ATTVAL_UNSIGNEDSHORT, //65535 | java.sql.Types.INTEGER |
SchemaSymbols.ATTVAL_UNSIGNEDBYTE, //255 | java.sql.Types.SMALLINT |
SchemaSymbols.ATTVAL_POSITIVEINTEGER | java.sql.Types.INTEGER |
SchemaSymbols.ATTVAL_FLOAT | java.sql.Types.FLOAT |
SchemaSymbols.ATTVAL_DOUBLE | java.sql.Types.DOUBLE |
SchemaSymbols.ATTVAL_DECIMAL | java.sql.Types.DECIMAL |
SchemaSymbols.ATTVAL_STRING | java.sql.Types.VARCHAR |
SchemaSymbols.ATTVAL_DATE | java.sql.Types.DATE |
SchemaSymbols.ATTVAL_TIME | java.sql.Types.TIME |
SchemaSymbols.ATTVAL_DATETIME | java.sql.Types.TIMESTAMP |
SchemaSymbols.ATTVAL_HEXBINARY | java.sql.Types.LONGVARBINARY |
Note: When you import data of List type from an XSD file, you can define the delimiter through the property List Delimiter in the Report Inspector.
XSD structure supported by JReport Designer
In JReport Designer, not all XSD structures can be supported. The following diagrams show which structures are supported by JReport Designer.
The Element type in the diagram can be of simpleType, ref, or complexType (it is different from the ComplexType in the root of this diagram. It can be global complexType but cannot be the anonymous one. If you have defined a complexType named A, and in this complexType A redefined an element as complexType named B, then the elements belong to complexType B must be of the simpleType).
The Attribute type in the diagram should be of the anonymous type or of the schema built-in type, such as xs:string.
SimpleType here should be of the schema built-in type, such as xs:string. List type here cannot support some functions, such as minLength, and maxLength.
ComplexType here can include both global and anonymous complexType. The anonymous type means you do not give a name to the type, for example,
|
From the code above, you can see that the simpleType in the element aa has no name specified.