Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML File from several Cursors with 1 cursor without relation
Message
From
29/04/2019 17:19:00
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
XML File from several Cursors with 1 cursor without relation
Miscellaneous
Thread ID:
01668303
Message ID:
01668303
Views:
83
Hello community,

I have found this example to generate XML file With associated XSD, but i want create the same example using another cursor that as no Key to associate to tables customers and Orders and OrdersDetails, like on the example:
Select customers
Set Relation To customerid Into crsOrders In crsCustomer
Set Relation To orderid Into crsOrdDet In crsOrders Additive
In this case how can do that?, for example i use on example above the table Territories (Suppose this table contains my enterprise data informations), i don´t have any field to create relation between the other tables ?
Also, i need my company information on the main TAG like :
<Enterprise>
    <territoryid>02116</territoryid>
    <territorydescription>Boston</territorydescription>
    <regionid>1</regionid>
	<MyCustomer>
		<customerid>BONAP</customerid>
		<companyname>Bon app'</companyname>
		<contactname>Laurence Lebihan</contactname>
		<contacttitle>Owner</contacttitle>
		<address>12, rue des Bouchers</address>
		<city>Marseille</city>
		<postalcode>13008</postalcode>
		<country>France</country>
		<phone>91.24.45.40</phone>
		<fax>91.24.45.41</fax>
		<MyOrders>
			<orderid>10331</orderid>
			<customerid>BONAP</customerid>
			<employeeid>9</employeeid>
			<orderdate>1996-10-16</orderdate>
			<requireddate>1996-11-27</requireddate>
			<shippeddate>1996-10-21</shippeddate>
			<shipvia>1</shipvia>
			<freight>10.1900</freight>
			<shipname>Bon app'</shipname>
			<shipaddress>12, rue des Bouchers</shipaddress>
			<shipcity>Marseille</shipcity>
			<shippostalcode>13008</shippostalcode>
			<shipcountry>France</shipcountry>
			<MyOrderDetails>
				<orderid>10331</orderid>
				<productid>54</productid>
				<unitprice>5.9000</unitprice>
				<quantity>15</quantity>
				<discount>0.00000</discount>
			</MyOrderDetails>
		</MyOrders>
</Enterprise>
Finally, if i want to remove from the XML file the XSD content , how can do that ?

The code i use to produce the XML and XSD file is:
CLOSE DATABASES ALL
OPEN DATABASE (HOME() + [samples\northwind\northwind])

USE territories IN 0
USE customers IN 0
USE orders IN 0
USE OrderDetails IN 0

SELECT * ;
	FROM territories ;
	WHERE territoryid = '02116' ;
	into cursor crsTerritory
	

Select customers.* ;
  from customers ;
  where customerid = 'BONAP' ;
  into Cursor crsCustomer nofilter

Select t1.* ;
  from orders t1 ;
  inner Join crsCustomer t2 On t1.customerid = t2.customerid ;
  into Cursor crsOrders nofilter
Index On customerid Tag customerid

Select t1.* ;
  from OrderDetails t1 ;
  inner Join crsOrders t2 On t1.orderid = t2.orderid ;
  into Cursor crsOrdDet nofilter
Index On orderid Tag orderid

SELECT territories
*set fields TO territorydescription

Select customers
*SET RELATION TO territorydescription INTO crsOrders In crsCustomer
Set Relation To customerid Into crsOrders In crsCustomer
Set Relation To orderid Into crsOrdDet In crsOrders Additive

Local loAdapter As Xmladapter ,loAdapter2 As Xmladapter
loAdapter = Createobject('XMLAdapter')
loAdapter.AddTableSchema('crsTerritory',.T.,Strconv('Enterprise',12))
loAdapter.AddTableSchema('crsCustomer',.T.,Strconv('MyCustomer',12))
loAdapter.AddTableSchema('crsOrders',  .T.,Strconv('MyOrders',12),'','',.F.,.F.,.T.)
loAdapter.AddTableSchema('crsOrdDet',  .T.,Strconv('MyOrderDetails',12),'','',.F.,.F.,.T.)
loAdapter.RespectNesting = .T.
loAdapter.ToXML('cMyData','',.T.)
MODIFY FILE cMyData.xml
Many thanks,
Best regards,
Luis
Next
Reply
Map
View

Click here to load this message in the networking platform