16.20 - retainedElements Element - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantageā„¢ XML Data Type

Teradata Database
Teradata Vantage NewSQL Engine
Release Number
Release Date
March 2019
Content Type
Programming Reference
Publication ID
English (United States)

XML shredding is performed in a streamed fashion in which the XML document is processed in one pass as a stream of characters. One consequence of this is that no state is maintained. For example, element values are discarded as the parser moves on to the next element. However, in some cases, some values occurring in a subtree early in the document might be of use throughout the document.

Consider an XML document that represents purchase orders for an entire day of sales for a store:

      <store no="12345"/>
      <!-- content of the purchase order -->
      <!--content of the purchase order -->
   <!--  more purchaseorders -->

The /purchaseorders/meta/date element identifies the date that applies to all the purchase orders in the document. In this case, the shredding processor must retain this element throughout the processing of the document. To use the minimum amount of memory, the mapping should indicate which elements need to be retained. For this purpose, use the retainedElements instruction as follows:

   <element ref="_meta_item" path="purchaseorders/meta"/>
   <!-- more retained element can be appended -->