Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Xmladapter ??
Message
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01185946
Message ID:
01185960
Views:
21
I think you have it a little backwards...

If they are providing YOU the XML, and you want to get into cursors, you need to READ the XML through the adapter, then have the adapter open the cursors based on the definition of the schemas provided in the XML... Something like...
oXMLAdapter = NEWOBJECT("XMLAdapter")

*/ Import hierarchial data into XMLAdapter cursors
oXMLAdapter.LoadXML(lcXMLFromPeopleSoft)
			
*/ Loop through each cursor in XMLAdapter and update VFP tables
FOR lnI = 1 TO oXMLAdapter.Tables.Count
   */ Get XMLAdapter cursor
   oXMLTable = oXMLAdapter.Tables.Item(lnI)

   */ Make sure any cursors by same name are already closed,
   */ otherwise an error will be thrown ALIAS IN USE...
   USE IN ( SELECT( oXMLTable.Alias ))

   */ Just open the cursor - in full
   oXMLTable.ToCursor()
ENDFOR 
>I have the following schema to work with (coming from peoplesoft):
>
>http://www.cortiel.com/xml_schema-ott.png
>
>
>and am trying to read in the XML into a set of cursors
>
>	
>CREATE CURSOR CT_API001_HDR (;
>	business_unit C(5)  DEFAULT "OTTIU" ,;
>	Voucher_id c(10),;
>	ct_vchr_intfc_srce c(3),;
>	origin c(3)  DEFAULT "OTT",;
>	invoice_id i ,;
>	invoice_dt D,;
>	accounting_dt d,;
>	vendor_setid c(5)  DEFAULT "OTTIU",;
>	name1 c(60),;
>	name2 c(60),;
>	vndr_name_shrt_usr c(9),;
>	ct_receipt_dt d,;
>	country c(3) DEFAULT "USA",;
>	address1 c(60),;
>	address2 c(60),;
>	address3 c(60),;
>	city c(30),;
>	state c(2),;
>	postal c(10),;
>	oprid c(10) DEFAULT "IacinoP",;
>	gross_amt n(17,2))
>	
>CREATE CURSOR CT_API001_PMNT(;
>	business_unit C(5)  DEFAULT "OTTIU" ,;
>	Voucher_id c(10),;
>	message_CD c(5) DEFAULT "UNCLAI",;
>	pymnt_gross_amt n(17,2),;
>	pymnt_handling_cd c(2) DEFAULT "RE")
>
>INDEX ON voucher_id	TAG voucher_id
>
>CREATE CURSOR CT_API001_LINE(;
>	business_unit C(5)  DEFAULT "OTTIU" ,;
>	Voucher_id c(10),;
>	voucher_line_num n(2,0) DEFAULT 1,;
>	line_descr c(50),;
>	merchandise_amt n(17,2))
>INDEX ON voucher_id	TAG voucher_id
>
>CREATE CURSOR CT_API001_Dist(;
>	business_unit C(5)  DEFAULT "OTTIU" ,;
>	Voucher_id c(10),;
>	voucher_line_num n(2,0) DEFAULT 1,;
>	distrib_line_num n(2,0) DEFAULT 1 ,;
>	merchandise_amt n(17,2) ,;
>	business_unit_gl C(5)  DEFAULT "OTTIU" ,;
>	account c(10),;
>	fund_code c(5) DEFAULT "11000",;
>	class_fld c(5) DEFAULT "12002",;
>	program_code c(5) DEFAULT "13019",;
>	project_id c(20) DEFAULT "OTT_NONPROJECT",;
>	deptID c(8) default "OTT14620",;
>	budget_dt d,;
>	budget_ref c(4) defa "2007")
>	
>INDEX ON voucher_id	TAG voucher_id
>	
>	
>	
>SET STEP ON
>
>
>* Create XML  (Thanks to Sergey)
>oXA = CREATEOBJECT("XmlAdapter")
>* The next setting is required to create nested XML
>oXA.RespectNesting = .T.
>oXA.AddTableSchema("CT_API001_HDR")
>oXA.AddTableSchema("CT_API001_PMNT")
>oXA.AddTableSchema("CT_API001_LINE")
>oXA.AddTableSchema("CT_API001_Dist")
>* Save XML in the current directory
>oXA.ToXML("CTAPI001A.xml",,.T.)
>* View created XML
>Modify Command CTAPI001A.xml
>*
>* Now load created XML back
>*
>*CLOSE DATABASES ALL
>* Load XML
>fname=[c:\Users\cortiel\Desktop\UPS-CORE\ACS-CTAPI001OTT20070111.xml]	
>
>oXA = CREATEOBJECT("XmlAdapter")
>oXA.AddTableSchema("CT_API001_HDR")
>oXA.AddTableSchema("CT_API001_PMNT")
>oXA.AddTableSchema("CT_API001_LINE")
>oXA.AddTableSchema("CT_API001_Dist")
>oXA.LoadXML(fname,.T.)
>FOR i=1 TO oXA.Tables.Count
>    oXA.Tables(i).Tocursor()
>ENDFOR
>SET
>
>
>
>
>but the cursors don't get created or filled :-)
>by the way there is not xml header in the file whatsoever
>
>any help would be appreciated
Previous
Reply
Map
View

Click here to load this message in the networking platform