Example: Using XSLTTRANSFORM to Transform an XML Value - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
SELECT customerXML.XSLTTRANSFORM(new XML('<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="/Customer">
      <html>
      <title>Items Ordered</title>
      <body>
      <table border="1">
      <tr>
         <th>Item ID</th>
         <th>Description</th>
         <th>Part Number</th>
         <th>Qty</th>
         <th>Unit Price</th>
         <th>Total Price</th>
      </tr>
      <xsl:for-each select="Order/Item">
      <tr>
         <td><xsl:value-of select="@ID"/></td>
         <td><xsl:value-of select="Description"/></td>
         <td><xsl:value-of select="PartNumber"/></td>
         <td><xsl:value-of select="Quantity"/></td>
         <td><xsl:value-of select="UnitPrice"/></td>
         <td><xsl:value-of select="Price"/></td>
      </tr>
      </xsl:for-each>
      </table>
      </body>
      </html>
   </xsl:template>
</xsl:stylesheet>'), '')
FROM customer
WHERE customerID = 1;

Here are partial results from the query. The ellipsis (...) is not part of the query results. It indicates that the query returns additional results that are truncated in the example.

customerXML.XSLTTRANSFORM( NEW XML('<?xml version="1.0" encoding...
-------------------------------------------------------------------
<html><title>Items Ordered</title><body><table border="1"><tr><th>Item ID</
th><th>Description</th><th>Part Number</th><th>Qty</th><th>Unit Price</th><th>Total
Price</th></tr><tr><td>001</td><td>Motoro...