XMLDocument.Transform
From Xojo Documentation
Method
Creates a new XML document that is the result of applying an XSLT stylesheet.
Method
XMLDocument.Transform(xsl as XMLStyleSheet,[saxHandler as XmlXsltHandler]) As String
Supported for all project types and targets.
Supported for all project types and targets.
Creates a new XML document that is the result of applying an XSLT stylesheet. Optionally register an event handler saxHandler to receive SAX style events on the output XML during the transformation.
Notes
Versions 1.0 of XSLT and XPath are supported. XSLT is described at: https://www.w3.org/TR/xslt/all/ and XPath at https://www.w3.org/TR/xpath/all/.
Sample Code
Pretty-Printing XML
You can use XMLDocument.Transform to generate pretty-printed XML data using the following XSL.
<?xml version="1.0" encoding="UTF-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <xsl:copy-of select="/" /> </xsl:template> </xsl:transform>
Save it in a project as a constant named kPrettyPrintXSL. Then the following code generates pretty-printed XML data from an XMLDocument object.