17.10 - Example: XSLT_SHRED_BATCH <xsl:value-of select=""> - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - XML Data Type

Advanced SQL Engine
Teradata Database
Release Number
July 2021
Last Update
Content Type
Programming Reference
Publication ID
English (United States)
Last Update

This example shows how to use the <xsl:value-of select=""> mapping definition. In <xsl:value-of select=""> mappings the column and element names are different.

Before running the example, ensure the test user is created with the required permissions and the required tables are created. See Setting Up the XSLT_SHRED_BATCH and XSLT_SHRED Examples for details.

Populate the staging table used to store the XML source document.

DELETE Input_Docs;

INSERT INTO Input_Docs VALUES(1, CREATEXML('<?xml version="1.0"?>

Call the XSLT_SHRED_BATCH stored procedure with the stylesheet mapping to shred the XML data stored in the staging input table. The following arguments are used for the call.

  • The queryString is: sel * from xsltuser.Input_Docs
  • The xsltMapping argument is supplied by invoking the CREATEXML function with a stylesheet as input. This stylesheet will be applied to the XML document.
  • The externalContext is NULL for this example.
  • The resultCode is returned in :res. A successful operation returns 0.
CALL TD_SYSXML.XSLT_SHRED_BATCH('sel * from xsltuser.Input_Docs', CREATEXML('<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/Root">
    <xsl:for-each select="predictixOfferMessage">
      <C_COL1><xsl:value-of select="Offer/offerid"/></C_COL1>
      <C_COL2><xsl:value-of select="mediaBlock/mediaBlockid"/></C_COL2>
'), NULL, :res);
Result: To view the updated data in the target table, run: SELECT * FROM Offer1;
C_COL1     C_COL2
----------  -------------------------------------------
1000003     90000000010003