I am using the CR 2011 developer
tool to try and consume XML data using the HTTP XML URL option under XML
and Web Services. At least this is my ultimate goal. I have hit a bit
of a road block in that Crystal seems unable to correctly represent
sibling elements belonging to a common parent. I have constructed a
simplified example of what my XML looks like. A salesperson is assigned
to two different regions and to two different accounts. The regions and
accounts exist as sibling elements belonging to the parent
salesperson. When I insert the sales_person_name, region_name and
account_name into the details section of the report I expect to see four
rows. The four rows would represent each combination of region and
account for this single salesperson. Instead I only get three rows. I
see this behavior when using either HTTP XML URL or Local XML File
options under XML and Web Services. Each option requires I supply a
schema which I have also supplied below. I do not see the same behavior
when viewing the same data using the ADO.NET XML data connection
option. Unfortunately this option is not sufficient as it simply offers the ability to consume a static
XML file. I must have the ability to generate a Web Service request via
URL and apply arguments to the request.
I
am wondering if I am doing something wrong or perhaps this type of XML
structure is not supported by these data connection options? I would
welcome any suggestions on how I can make this work. It is not
practical for me to change the XML structure for all the different Web
Services that might be used as a report data source however.
I
am also curious as to whether others have attempted to use Crystal
reports and the HTTP XML URL option under XML and Web Services as a data
connection.
<?xml version="1.0" encoding="UTF-8"?>
<sales>
<salesperson>
<sales_person_id>1</sales_person_id>
<sales_person_name>Joe Smith</sales_person_name>
<region>
<region_id>3</region_id>
<region_name>Northwest US</region_name>
<country>US</country>
</region>
<region>
<region_id>19</region_id>
<region_name>Southeast England</region_name>
<country>UK</country>
</region>
<account>
<acct_id>100</acct_id>
<account_name>ACME Corp</account_name>
<account_level>Level 1</account_level>
</account>
<account>
<acct_id>200</acct_id>
<account_name>Generic Co.</account_name>
<account_level>Level 2</account_level>
</account>
</salesperson>
</sales>
The schema
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sales">
<xs:complexType>
<xs:sequence>
<xs:element name="salesperson" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="sales_person_id"/>
<xs:element type="xs:string" name="sales_person_name"/>
<xs:element name="region" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="region_id"/>
<xs:element type="xs:string" name="region_name"/>
<xs:element type="xs:string" name="country"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="account" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="acct_id"/>
<xs:element type="xs:string" name="account_name"/>
<xs:element type="xs:string" name="account_level"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>