Repeated Processing Instructions in Generic XML

Additional declarations are required when extracting data from repeated structures below the record node. Declaration of a repeated node happens with the <?Repeated [OptionalSpaceSeparatedFilters]?> processing instruction. The <?Repeated?> instruction must be placed inside <?Record?> scope. For example:

Copy
<Products>
   <Product ID="EXA-5002-1004">
      <Values>
         <Value AttributeID="52">Some description text</Value>
         <Value AttributeID="77">53 kg</Value>
      </Values>
    </Product>
</Products>    

Note that the Value node is repeated. To extract data from both occurrences, the template must declare that a node is a repeated node, which means that a set of fields has to be generated for each node encountered. The template also has to declare an ID source on or below the repeated node.

The following template could be used to extract the data from the above Generic XML:

Copy
<Products>
  <Product ID="[?Source ID?]">
  <?Record?>
    <Values>
      <Value AttributeID="[?SourceID?]"><?Repeated?><?Source?></Value>
    </Values>
  </Product>
</Products>    

The ID source is used to map each occurrence of a repeated node to a specific set of fields of the form [Identifier].[SourceTagName]. This is required to ensure that related repeated nodes map to the same fields across different records.

By default, a repeated scope produces a set of fields for each ID Source value encountered in the input document. Using the 'optional space separated filters' allows you to select values from specific ID keys or to guard against additional columns being generated as input documents evolve in the future.

Copy
<ARTICLE>
   <ARTICLE_PRICE_DETAILS>
      <DATETIME type="valid_start_date">
      <DATE>2010-01-01</DATE>
      </DATETIME>
   <PRODUCT_PRICE price_type="net_list">
      <PRICE_AMOUNT>11.08</PRICE_AMOUNT>
      <PRICE_CURRENCY>EUR</PRICE_CURRENCY>
      <TAX>0.19</TAX>
      <LOWER_BOUND>1</LOWER_BOUND>
   </PRODUCT_PRICE>
   <PRODUCT_PRICE price_type="nrp">
      <PRICE_AMOUNT>23.05</PRICE_AMOUNT>
      <PRICE_CURRENCY>EUR</PRICE_CURRENCY>
      <TAX>0.19</TAX>
      <LOWER_BOUND>1</LOWER_BOUND>
   </PRODUCT_PRICE>
   <PRODUCT_PRICE price_type="employee">
      <PRICE_AMOUNT>8.52</PRICE_AMOUNT>
      <PRICE_CURRENCY>EUR</PRICE_CURRENCY>
      <TAX>0.19</TAX>
      <LOWER_BOUND>1</LOWER_BOUND>
   </PRODUCT_PRICE>
   </ARTICLE_PRICE_DETAILS>
</ARTICLE>    

The price and currency information can be extracted for the net_list and nrp price types only by following the proceeding steps and using the following template:

  1. Copy the above Generic XML to a new file, and save as an XML file
  2. Open Import Manager, select the file as the Data Source Filename, and click 'Next'
  3. The user can enter/ paste the template below in the Import Manager, and a conversion preview can be generated by clicking the refresh button, .
Copy
<ARTICLE>
   <?Record?>
   <ARTICLE_PRICE_DETAILS>
      <PRODUCT_PRICE price_type="[?SourceID?]">
      <?Repeated net_list nrp?>
      <PRICE_AMOUNT><?Source Amount?></PRICE_AMOUNT>
      <PRICE_CURRENCY><?Source Currency?></PRICE_CURRENCY>
      </PRODUCT_PRICE>
   </ARTICLE_PRICE_DETAILS>
</ARTICLE>    

This produces the fields:

  • net_list.Amount = 11.08
  • net_list.Currency = EUR
  • nrp.Amount = 23.05
  • nrp.Currency = EUR

The <?Repeated?> instruction can take an arbitrary number of filter terms separated by white-space characters. When no terms are defined, the filtering functionality is disabled.