Print Page | Close Window

XML and Web Services - Data relationships

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19755
Printed Date: 11 May 2024 at 11:27pm


Topic: XML and Web Services - Data relationships
Posted By: dnewton
Subject: XML and Web Services - Data relationships
Date Posted: 11 Jul 2013 at 5:12am

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 - 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>



-------------
dnewton



Replies:
Posted By: lockwelle
Date Posted: 19 Jul 2013 at 5:28am
ADO is not for a static file...since I have used that type of connection for years. Rather, I would set the Datasource of the report to an XML file with same schema that the report was designed against.

I will agree, that if you put a file out on a server, ADO will not 'read' it until you 'verify the database'...

I realize that this was posted a while ago, and a solution may already have been reached. I just thought that I would give my experience with ADO connections.

HTH



Print Page | Close Window