17.10 - retainedElements Element - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1140-171K
Language
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:

<purchaseorders>
   <meta>
      <store no="12345"/>
      <date>09/11/2011</date>
   <meta>
   <purchaseorder>
      <!-- content of the purchase order -->
   </purchaseorder>
   <purchaseorder>
      <!--content of the purchase order -->
   </purchaseorder>
   <!--  more purchaseorders -->
</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:

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