Structuring XML Data For The Crystal Reports XI Native XML Driver
Structuring XML Data For The Crystal Reports XI Native XML Driver
Overview
This document provides suggestions to known issues in the use of the
Crystal Reports Native XML driver. It provides sample scripting and
illustrates the best methods to structure your XML schemas and XML
instances. This document applies to Crystal Reports XI and later.
Contents
INTRODUCTION ............................................................................................ 2
IMPORTANT FACTS AND SUGGESTIONS ........................................................ 2
Installing the CR XML Native Driver........................................................... 2
Validate XML instance against schemas ...................................................... 2
Steps to Test the XML..................................................................................... 3
JVM memory issues with large XML files ................................................... 3
Out-of-memory error with a large XML instance....................................... 4
Avoid many-to-many relationships in your XML schema........................ 7
Native XML driver performance issue with a large XML instance.......... 9
KNOWN ISSUES AND LIMITATIONS .............................................................. 10
Avoid creating cyclic references in your schema...................................... 10
Including or importing a local file .............................................................. 10
Special character restrictions ....................................................................... 10
Inline schema................................................................................................. 10
XML from Microsoft ADO is not supported prior to Crystal Reports XI
Release 2 ......................................................................................................... 11
Extended type binding not supported by Native XML driver ............... 11
Simple elements mapped to a field............................................................. 12
BusinessObjects Enterprise XI and the Native XML driver..................... 13
Mixed attributes are not supported in XML schemas .............................. 13
The Native XML driver only supports latest XML schema spec ............ 14
Defined namespaces in your XML schema ............................................... 15
FINDING MORE INFORMATION .................................................................... 15
6/30/2006 2:56:00 PM Copyright © 2006 Business Objects. All rights reserved. Page 1
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Introduction
The Crystal Reports Native XML driver was introduced in Crystal
Reports version 10. How your XML schemas and XML instances are
structured has a powerful impact on report processing speed when using
that driver.
The driver has some limitations and known issues. These issues have
been assigned Track ID ADAPT00594769 and ADAPT00586094.
Limitations are discussed towards the end of this document.
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-
us/samples/internet/xml/xml_validator/default.asp
The XML Validator will verify that the XML is well formed, valid and
error free. Also, this utility indicates elements such as parent/child tags
and any attributes associated to elements within the XML and the XML
hierarchy structure. You will be able to identify any Table or Row hints
for the CR XML driver to use. Table and Row hints are discussed later in
this document.
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
The XML Validator can be used with both XML schemas and Data Type
Definitions (DTDs), allows you to verify unsecured URL XML, and to
paste any particular XML to test.
<JVMMaxHeap>1024000000</JVMMaxHeap>
<JVMMinHeap>512000000</JVMMinHeap>
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Alternatively, you can organize your XML schema in blocks. This way
the Crystal Reports Native XML driver consumes little memory while
processing data in streaming mode. In the following example, element
Title and Author are structured in one block, following the
recommended structure.
Example 1:
<Library>
<Book>
<Title>Pride and Prejudice</Title>
<Author>
<First Name>
Jane
</Last Name>
</Last Name>
Austen
</Last Name>
</Author>
</Book>
……
……
……
<Book>
<Title>Great Expectations</Title>
<Author>
<First Name>
Charles
</First Name>
<Last Name>
Dickens
</Last Name>
</Author>
</Book>
</Library>
In Example 2 a new element, Library Info, is added. Since the driver can
not know in advance if the Library Info element refers to a Book element,
it can not process the file in streaming mode. Depending on the size of
the XML data, this may cause performance degradation.
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Example 2:
<Library>
<Book>
<Title>Pride and Prejudice</Title>
<Author>
<First Name>
Charles
</First Name>
<Last Name>
Dickens
</Last Name>
</Author>
</Book>
……
……
……
<Book>
<Title>Great Expectations</Title>
<Author>
<First Name>
Charles
</First Name>
<Last Name>
Dickens
</Last Name>
</Author>
</Book>
<Library Info>
<Name>
Shanghai Library
</Name>
<Total Circulation>
130,000,000
</Total Circulation>
<Library Info>
</Library>
How much memory the Native XML driver will consume is proportional
to how much of the XML file the driver has to read in order to create
each report record detail.
For example, if a user selects one table in the XML instance, even if the
XML instance is very large, Native XML driver will only consume a
small amount of memory.
However, if you select several tables which are widely distributed, for
example, one at the top of the XML instance, several in the middle, and
one at the bottom, the Native XML driver has to read the entire XML
instance to generate one record. This can cause the Native XML driver to
use more memory resulting in performance degradation.
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
In the following example, if a user selects one book record in the library,
the Native XML driver will consume a small amount of memory, even if
the XML instance is quite large. However, if a user selects Library Name,
several Book and Total Circulation, the Native XML driver will
consume a larger amount of memory relative to the size of the XML
instance. You may encounter an out-of-memory error.
Example 3:
<Library>
< Library Name>
Shanghai Library
</Library Name>
<Book>
<Title>Design UK</Title>
<Author>
<First Name>
Max
</First Name>
<Last Name>
Fraser
</Last name>
<Author>
</Book>
…
<Book>
<Title>The Diary Of A Young Girl</Title>
<Author>
<First Name>
Anne
</First Name>
<Last Name>
Frank
</Last name>
<Author>
</Book>
…
<Book>
<Title>BILLY BUDD SAILOR</Title>
<Author>
<First Name>
Herman
</First Name>
<Last Name>
Melville
</Last name>
<Author>
</Book>
<Total Circulation>
130,000,000
</Total Circulation>
</Library>
6/30/2006 Copyright © 2006 Business Objects. All rights reserved. Page 6
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Example 4:
<Company>
<Sales Agent>
<Location>Beijing </Location>
</Sales Agent>
<Sales Agent>
<Location>Shanghai </Location>
</Sales Agent>
<Product>
<Name>Refrigerator </Name>
<Manufacturer>
<Name>
Haier
</Name>
<Contact Person>
<Name>
Mark Williams
</Name>
<Phone Number>
+862151525354
</Phone Number>
</Contact Person>
</Manufacturer>
</Product>
<Product>
<Name>TV</Name>
<Manufacturer>
<Name>
CHONGHONG
</Name>
<Contact Person>
<Name>
Steve Nash
</Name>
<Phone Number>
+862188888888
</Phone Number>
</Contact Person>
</Manufacturer>
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
</Product>
</Company>
Example 5:
<Company>
<Sales Agent>
<Location>Beijing</Location>
<Product>
<Name> Refrigerator </Name>
<Manufacturer>
<Name>
Haier
</Name>
<Contact Person>
<Name>
Mark Williams
</Name>
<Phone Number>
+862151525354
</Phone Number>
</Contact Person>
</Manufacturer>
</Product>
<Product>
<Name>TV</Name>
<Manufacturer>
<Name>
CHONGHONG
</Name>
<Contact Person>
<Name>
Steve Nash
</Name>
<Phone Number>
+862188888888
</Phone Number>
</Contact Person>
</Manufacturer>
</Product>
</Sales Agent>
<Sales Agent>
<Location>Shanghai</Location>
<Product>
<Name> Refrigerator </Name>
<Manufacturer>
<Name>
Haier
</Name>
6/30/2006 Copyright © 2006 Business Objects. All rights reserved. Page 8
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
<Contact Person>
<Name>
Mark Williams
</Name>
<Phone Number>
+862151525354
</Phone Number>
</Contact Person>
</Manufacturer>
</Product>
<Product>
<Name>TV</Name>
<Manufacturer>
<Name>
CHONGHONG
</Name>
<Contact Person>
<Name>
Steve Nash
</Name>
<Phone Number>
+862188888888
</Phone Number>
</Contact Person>
</Manufacturer>
</Product>
</Sales Agent>
</Company>
Too much data in one XML file risks causing unrelated join issues. The
joins within one XML file can also prevent efficient streaming-style
processing of the data if not structured well.
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Inline schema
Inline Schema support is introduced in Crystal Reports XI Release 2. Do
not use inline schema in your XML file for versions prior to Crystal
Reports XI Release 2.
Example 6:
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:inl="http://inline">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Example 7:
…
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Example 8:
<StockItem>
<Item>A100</Item>
<Item>A200</Item>
<Item>A300</Item>
<Item>A400</Item>
</StockItem>
If you select Items in your report, you probably want to see the four
items formatted the following
Item
A100
A200
A300
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
A400
Item
<Item>A100</Item><Item>A200</Item>
<Item>A300</Item><Item>A400</Item>
Example 9:
<StockItem>
<Item>A100</Item>
</StockItem>
<StockItem>
<Item>A200</Item>
</StockItem>
<StockItem>
<Item>A300</Item>
</StockItem>
<StockItem>
<Item>A400</Item>
</StockItem>
With mixed enabled, the XML Schema provides for the construction of
schemas where character data can appear alongside sub elements, and
character data is not confined to the deepest sub elements.
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
Example 10:
<letterBody>
<salutation>
Dear Mr.
<name>Robert Smith </name>.
</salutation>
Your order of
<quantity>1</quantity>
<productName> Baby Monitor </productName>
shipped from our warehouse on
<shipDate> 1999-05-21 </shipDate>. ....
</letterBody>
Example 12:
<xsd:element name="letterBody">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="salutation">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="quantity" type="xsd:positiveInteger"/>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="shipDate" type="xsd:date" />
<! -- Etc. -->
</xsd:sequence>
</xsd:complexType>
</xsd:element>
The Native XML driver only supports latest XML schema spec
The Native XML driver only supports the latest XML schema
specifications. References to older schema specifications should be
replaced with the newest version.
cr_xi_native_xml_driver.pdf
Crystal Reports XI Structuring XML Data for use with the Crystal Reports XI Native XML Driver
http://support.businessobjects.com/communityCS/TechnicalPapers/cr
_xml_data_sources.pdf.asp
www.businessobjects.com
No part of the computer software or this document may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system,
without permission in writing from Business Objects.
The information in this document is subject to change without notice. Business Objects does not warrant that this
document is error free.
This software and documentation is commercial computer software under Federal Acquisition regulations, and is
provided only under the Restricted Rights of the Federal Acquisition Regulations applicable to commercial computer
software provided at private expense. The use, duplication, or disclosure by the U.S. Government is subject to
restrictions set forth in subdivision (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at
252.227-7013.
The Business Objects product and technology are protected by US patent numbers 5,555,403; 6,247,008; 6,578,027;
6,490,593; and 6,289,352. The Business Objects logo, the Business Objects tagline, BusinessObjects,
BusinessObjects Broadcast Agent, BusinessQuery, Crystal Analysis, Crystal Analysis Holos, Crystal Applications,
Crystal Enterprise, Crystal Info, Crystal Reports, Rapid Mart, and WebIntelligence are trademarks or registered
trademarks of Business Objects SA in the United States and/or other countries. Various product and service names
referenced herein may be trademarks of Business Objects SA. All other company, product, or brand names
mentioned herein, may be the trademarks of their respective owners. Specifications subject to change without notice.
Not responsible for errors or omissions.
Copyright © 2006 Business Objects SA. All rights reserved.
cr_xi_native_xml_driver.pdf