BackPrevious Page Next PageNext

Importing an XML Schema

Importing from an XSD File

Importing by Parsing an XML Instance

Supplementing Information for the XML Schema

Before an XML schema is transformed to relational tables, it must be imported. JReport Designer provides two ways for you to import an XML schema: importing from an XSD file or parsing from an XML instance. After importing, in order to provide a precision schema to be transformed, you can supplement or modify properties of the imported schema according to your requirements.

Importing from an XSD file

In order to transform the imported XML schema to the relational schema, you can choose to import an XML schema by importing the structure of an XML data source and the information of its elements that are recorded in an XSD file.

You should be aware of the following about XSD in order to generate a correctly imported XML schema:

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 schema is imported following the rules in the conversion table below.

XSD Data Type SQL Data Type
BOOLEAN BIT
BYTE TINYINT
UNSIGNEDBYTE SMALLINT
SHORT SMALLINT
UNSIGNEDSHORT INTEGER
INT INTEGER
UNSIGNEDINT BIGINT
LONG BIGINT
UNSIGNEDLONG DECIMAL
NEGATIVEINTEGER DECIMAL
NONPOSITIVEINGEGER DECIMAL
POSITIVEINTEGER DECIMAL
NONNEGATIVEINTEGER DECIMAL
INTEGER DECIMAL
FLOAT FLOAT
DOUBLE DOUBLE
DECIMAL DECIMAL
STRING VARCHAR
NORMALIZEDSTRING VARCHAR
TOKEN VARCHAR
LANGUAGE VARCHAR
NAME VARCHAR
NMTOKEN VARCHAR
NMTOKENS VARCHAR
NCNAME VARCHAR
ID VARCHAR
IDREF VARCHAR
ENTITY VARCHAR
IDREFS VARCHAR
ENTITIES VARCHAR
ANYSIMPLETYPE VARCHAR
GYEAR VARCHAR
GYEARMONTH VARCHAR
GMONTH VARCHAR
GMONTHDAY VARCHAR
GDAY VARCHAR
DATE DATE
TIME TIME
DATETIME TIMESTAMP
HEXBINARY BLOB
BASE64BINARY BLOB

XSD syntax supported by JReport Designer

In JReport Designer, not all XSD syntax can be supported. The following diagram shows the XSD syntax that is supported by JReport Designer and syntax is in accordance with the W3C standard:

XML Schema::=

XSD syntax diagram

Text description of the XML Schema:

annotation*, ((element declaration | SimpleType| ComplexType | notation), annotation*)*;

Notes:

The following are diagrams showing the detail syntax of elements in the above diagram:

Namespace limitation in the XSD file

Default namespace (3w) and target namespace are supported by JReport Designer. You can define a prefix for the default namespace, such as xs, or xsd, but the value of elementFormDefault must be qualified. The value of attributeFormDefault should be unqualified, but JReport Designer will not allow you to add prefixes before the attributes of the elements.

Importing by parsing an XML instance

In order to transform the imported XML schema to the relational schema, you can also choose to parse an XML data source to get the XML structure. You should be aware of the following points about XSD in order to generate a correctly imported XML schema.

Supplementing information for the XML schema

When importing an XML schema, you can modify the properties or supplement some necessary information of the XML schema according to your own requirements in order to make it more useful to you.

The following are some special properties and its description for your reference:

Name

Displays the name of an element (), attribute () or a reference of element () in the XML instance.

Data Type

Specifies the data type of an element or attribute. The data type is imported when importing the XML schema from XSD file or given by JReport when parsing from XML source. This property on a reference of element cannot be modified.

Format Pattern Type

This property is activated when you modify properties for data of Date, Time or DateTime type in the XML schema. It can be Default or Customized:

Format Pattern

This property is available when you specify to parse data from the XML instance at runtime.

Is Multiple

Indicates whether or not an element occurs more than once in the XML instance. By default, the value of the Is Multiple property is affected by the value of its maxOccurs property in the XSD: if the value of maxOccurs property is greater than 1 or unbounded, it is true; otherwise, it is false. You can modify this property according to your own requirements.

List

Specifies whether or not to set the data type of an element or attribute as List. This property on a reference of element cannot be modified.

The following two properties are alternative:

Default Value

Specifies the default value for an element or attribute. If there is no specific value of an element or attribute in the XML schema, the default value you specify here will be applied; otherwise, the value in the XML schema for this element or attribute will be applied.

Fixed Value

Specifies the fixed value for an element or attribute, which will be applied no matter there is a value for the element or attribute.

Format patterns

A format pattern is a string and can be used for specifying patterns to format strings, which are in XML instance. JReport Format Pattern only supports specifying patterns to format time data type strings, such as date, time and datetime. You can customize the format pattern for date, time and datetime formats or use default ones.

In the process of transforming an XML schema to relational tables, you can choose to customize the format patterns for date, time and datetime formats in the XML schema or apply the default ones, which will comply with the W3C XML Schema 1.1 specification (for details, refer to the page http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#dateTime).

Customized format pattern

You can specify the date, time and datetime formats in XML schema by the date, time and datetime pattern strings or customize the format pattern by the Format Pattern dialog. In the dialog, the pattern string you select from the Pattern Fragments list box will be interpreted, and the delimiter that you input will not be interpreted. Any character is acceptable and it will be quoted if necessary.

Within date, time and datetime pattern strings in the XML schema, unquoted letters from A to Z and from a to z are interpreted as pattern letters representing the components of a date, time or datetime string. Text can be quoted using single quotes (') to avoid interpretation. '' represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing the XML schema.

DateTime format pattern

The DataTime format pattern consists of some pattern strings and delimiters. JReport provides the following pattern strings in the DataTime format pattern: G, yyyy, yy, MMMM, MM, dd, D, WW, ww, F, E, a, HH, kk, KK, hh, mm, ss, SSS, z, Z.

Letter Date Component Presentation Examples
G Era designator Text AD
y Year Year 1996; 96
M Month in year Month July; Jul; 07
w Week in year Number 27
D Day in year Number 189
d Day in month Number 10
F Day of week in month Number 2
E Day in Week Text Tuesday; Tue
a Am/pm marker Text PM
H Hour in day (0-23) Number 0
k Hour in day (1-24) Number 24
K Hour in am/pm (0-11) Number 0
h Hour in am/pm (1-12) Number 12
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978
z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
Z Time zone RFC 822 time zone -0800

Format pattern also supports localized date, time and datetime pattern strings. In these strings, the text presentation of pattern letters described in the above table may be varied with the locale.

Date format pattern

The representation of the format pattern for date data type in XML schema is same as datetime but the pattern strings are less than it. Only the following strings can be used: G, yyyy, yy, MMMM, MM, dd, D, WW, ww, F, E.

Time format pattern

The representation of the format pattern for time data type in XML schema is same as datetime but the pattern strings are less than it. Only the following strings can be used: a, HH, kk, KK, hh, mm, ss, SSS, z, Z.

BackPrevious Page Next PageNext