Skyhawk Systems - Simplify data transformations
Products | Download | Buy | About Us
 
Table of Contents Connect XML-2-DB User's Guide mapSequenceRule.htmTable of ContentsxmlPropagationRule.htm

5(k). Insertion Map Rule- <insertion-map>

For each table that records have to be inserted into, the user must define an insertion-map rule. This map rule determines after which XML element in the data file, an insert into the table should occur. Similarly, for each procedure that has to be invoked, the user must define an insertion-map rule. This rule determines after which XML element in the data file, the procedure should be invoked. The format of the insertion-map rule is as follows:

     <!ELEMENT insertion-map         EMPTY>
     <!ATTLIST insertion-map
          element-name         CDATA #REQUIRED
          table-reference       CDATA #IMPLIED
          proc-reference        CDATA #IMPLIED>
	

Either the table-reference attribute or the proc-reference attribute has to be provided.

Example:

For example, assume that you have the following XML data file that inserts records into the table SOFTWARE_SALES. Then each <software-sale> element logically corresponds to a record in the SOFTWARE_SALES table. The insertion-map rule would then associate the element software-sale with the table SOFTWARE_SALES. Since there are 2 occurences of the element software-sale, 2 records would be inserted into SOFTWARE_SALES.

<customer-purchases>
   <software-sale customer-first-name="Bill" customer-last-name="Smith" 
                  name="ABC Software" purchase-price="120.00" purchase-date="12/20/2001"
                  sales-agent="Patrick"/>
   <software-sale customer-first-name="John" customer-last-name="Bush" 
                  name="DZ Software" purchase-price="2000.00" purchase-date="10/10/2002"
                  sales-agent="Jane"/>
</customer-purchases>
	

The mapping file would have the following mapping rules defined in it:

	 <map-rules root-element="customer-purchases" map-version="1.0">

	   <table-reference-information 
	      table-reference="SoftwareSales" 
	      table-name="SOFTWARE_SALES" 
	      object-owner="TESTUSER"/>		      

	   <insertion-map element-name="software-sale" table-reference="SoftwareSales"/>
	   
	   <map 
	        element-name="software-sale" 
	        attribute-name="customer-first-name" 
	        table-reference="SoftwareSales" 
	        column-name="FIRST_NAME"/> 

	   <map
	        element-name="software-sale"
	        attribute-name="customer-last-name"
	        table-reference="SoftwareSales"
	        column-name="LAST_NAME"/> 

	   <map
	        element-name="software-sale"
	        attribute-name="name"
	        table-reference="SoftwareSales"
	        column-name="SOFTWARE_NAME"/>
	      
	   <map
	        element-name="software-sale"
	        attribute-name="purchase-price"
	        table-reference="SoftwareSales"
	        column-name="PURCHASE-PRICE"/>
	   
	   <map
	        element-name="software-sale"
	        attribute-name="purchase-date"
	        table-reference="SoftwareSales"
	        column-name="PURCHASE_DATE"/>

	   <map
	        element-name="software-sale"
	        attribute-name="sales-agent"
	        table-reference="SoftwareSales"
	        column-name="SALES_AGENT"/>

	   <map-const
	        element-name="software-sale"
	        constant-value="12/20/2001"
	        table-reference="SoftwareSales"
	        column-name="DATE_CREATED"/>
	   
	 </map-rules>
   
Copyright © Skyhawk Systems. All Rights Reserved.
Send comments and questions to support@skyhawksystems.com.
mapSequenceRule.htmTable of ContentsxmlPropagationRule.htm