retainedElements Element - Advanced SQL Engine - Teradata Database

XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
amr1556233250442.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1140
lifecycle
previous
Product Category
Teradata Vantageā„¢

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>