You can create an XSLT stylesheet that provides a mapping definition describing how an SQL query result is mapped to an XML tree structure. XSLT (eXtensible Stylesheet Language Transformation) is the language used for describing transformations from one XML structure to another or to other text formats. For XML publishing, use the mapping stylesheet to define a transformation from the canonical XML representation of a query result to the desired XML structure.
The following is an example of an XSLT mapping for publishing the results of the query shown in the previous section. The example defines a transformation from the canonical XML representation. For example, the xsl:for-each instruction constructs a customer element for each Row element in the canonical XML representation.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <customers> <xsl:for-each select="QuerySchema/ROW"> <customer teradata_group="CUSTID"> <CUSTID> <xsl:value-of select="CUSTID"/> </CUSTID> <CNAME> <xsl:value-of select="CNAME"/> </CNAME> <ACCTID> <xsl:value-of select="ACCTID"/> </ACCTID> <ANAME> <xsl:value-of select="ANAME"/> </ANAME> <ORDERID> <xsl:value-of select="ORDERID"/> </ORDERID> <ODATE> <xsl:value-of select="ODATE"/> </ODATE> <REPID> <xsl:value-of select="REPID"/> </REPID> <REPNAME> <xsl:value-of select="REPNAME"/> </REPNAME> <ITEMID> <xsl:value-of select="ITEMID"/> </ITEMID> <QTY> <xsl:value-of select="QTY"/> </QTY> </customer> </xsl:for-each> </customers> </xsl:template> </xsl:stylesheet>