>>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 ?
>><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 ?
>>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 >>>>
>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 > >Set Relation To customerid Into crsOrders In crsCustomer >Set Relation To orderid Into crsOrdDet In crsOrders > >******************************************************************* >Select crsCustomer >Index On customerid Tag customerid >Set Relation to '' Into crsCustomer In crsTerritory && cheat 1:1 relation >******************************************************************** > >loAdapter = Createobject('XMLAdapter') > >With loAdapter As Xmladapter > >************************************************************************ > .XMLName = strconv('XML',12) && change root <VFPDATA> TO <XML> > .XMLSchemaLocation = '' && supress XSD > .RespectNesting = .T. && set this default BEFORE adding tables, then no need to specify for each table >************************************************************************ > > .AddTableSchema('crsTerritory',.T.,Strconv('Enterprise',12)) > .AddTableSchema('crsCustomer',.T.,Strconv('MyCustomer',12)) > .AddTableSchema('crsOrders', .T.,Strconv('MyOrders',12)) > .AddTableSchema('crsOrdDet', .T.,Strconv('MyOrderDetails',12)) > .ToXML('cMyData','',.T.) > >Endwith > >Modify File cMyData.XML > >>
><?xml version = "1.0" encoding="Windows-1252" standalone="yes"?> ><XML> > <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> && is possible to remove this TAG > <productid>54</productid> > <unitprice>5.9000</unitprice> > <quantity>15</quantity> > <discount>0.00000</discount> > </MyOrderDetails> > </MyOrders> > </Enterprise> ></XML> > >>