Reference Guide > TDV Support for SQL Functions > TDV-Supported XML Functions > XSLT
 
XSLT
The XSLT function creates a new XML document based on the content of a source XML document. XSLT can be used to convert data from one XML schema to another, or to convert XML data into web pages or PDF documents.
Syntax
XSLT (sourceXml, xsltExpression)
Remarks
The first argument is the name of an XML document.
The second argument is a string value containing an XSLT expression.
The function evaluates the XSLT expression against the supplied XML value and returns the results as an XML value.
Note: For further information, refer to the open-source Saxon XSLT home page, http://saxon.sourceforge.net/.
Example
PROCEDURE XsltFunctionExample (OUT resultXml XML)
BEGIN
DECLARE sourceXml XML;
DECLARE xsltExpression VARCHAR(4096);
-- Create an XML value to use in the XSLT function.
SET sourceXml =
'<Book><Chapter>Test Data</Chapter></Book>';
-- Create an XSLT expression to evaluate.
SET xsltExpression =
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="true"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<itemA>
<xsl:for-each select="/Book">
<itemB>
<xsl:value-of select="Chapter"/>
</itemB>
</xsl:for-each>
</itemA>
</xsl:template>
</xsl:stylesheet>';
-- Evaluate the XSLT expression against the source XML value.
SET resultXml = XSLT (sourceXml, xsltExpression);
END