Handling Large XML Schema

How should you read in a large and complex XML file?

Reading a very large and complex XML file into memory all at once is not efficient. It causes large amounts of memory to be consumed and will degrade the Engine's performance.

Note: Remember that if you don't have an XSD file, it can be easily generated using an XML editor (like XML Spy).

By having an XSD file that you can introspect, there is a much more efficient technique that does not require that the whole file be read into memory. The code shown below does not read the XML whole file into memory and only accesses the file when it needs to read in more object information from it.

After introspecting the XML , create a new BPM Object method:
	// In production, do not hard code a local directory 
	// like this. 
	// It is only here in this example for clarity. 
	
	customer as XMLCOmp.Customer.Customer
	customer = 
	  XMLCOmp.Customer.Customer("file://c:/tmp/customer.xml")
	
	display customer.billAddress
	display customer.custDisc
	display customer.customerName
	
	
The above code expects a "customer.xml" XML file in the "c:\tmp" directory. Use the following XML text as this customer.xml file for this example: :
	 <?xml version="1.0" encoding="ISO-8859-1" ?>
	 <Customer>
	         <CustomerCode>NEW</CustomerCode>
	         <CustomerName>John Smith</CustomerName>
	         <CustDisc></CustDisc>
	         <BillAddress>Madison 2939 NY</BillAddress>
	         <ShipAddress>Madison 2939 NY</ShipAddress>
	         <CodPay></CodPay>
	         <CustType></CustType>
	         <Mail>pp@com.com</Mail>
	 </Customer>