You can, but you do not have to: for a BO list to CSV a few lines of JavaScript in a script task are simpler than an XSLT. Both versions:
JavaScript (recommended):
// service flow script: tw.local.orders (list of Order) -> tw.local.csv (String)
var cols = ["number", "customer", "total", "status"];
var q = function (v) { v = (v === null || v === undefined) ? "" : String(v); return '"' + v.replace(/"/g, '""') + '"'; };
var lines = [cols.map(q).join(",")];
for (var i = 0; i < tw.local.orders.listLength; i++) {
var o = tw.local.orders[i];
lines.push(cols.map(function (c) { return q(o[c]); }).join(","));
}
tw.local.csv = "\ufeff" + lines.join("\r\n"); // BOM so Excel reads UTF-8XSLT - BPM's business objects serialise to XML (tw.local.orders.toXML() returns the XML document, toXMLString() the text), and an XSL transformation (the System Data toolkit's XML transformation service, or javax.xml.transform from a script) applies a stylesheet stored as a managed asset:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">number,customer,total,status
<xsl:for-each select="//Order">"<xsl:value-of select="number"/>","<xsl:value-of select="customer"/>",<xsl:value-of select="total"/>,"<xsl:value-of select="status"/>"
</xsl:for-each></xsl:template>
</xsl:stylesheet>
// script: xml = tw.local.orders.toXML(); then the transform step with the stylesheet -> tw.local.csv
var xml = tw.local.orders.toXML(); // XMLDocument / E4X on 8.5.x; String on BAW 20+ (toXMLString)
Deliver the CSV: tw.system.createDocument("orders.csv", "text/csv", tw.local.csv, false) to attach it to the instance, or return it from a service called by a coach and download it client-side (new Blob([csv], {type: "text/csv"}) + a link, as the UI Toolkit table's export does). Use XSLT when the same stylesheet is shared with other systems or the transformation is complex; otherwise JavaScript.
References