Here's some code that'll use Xalan to transform an XML document with an XSLT
stylesheet, for all of us that don't want to use the gawd-awful MSXML COM object and
don't yet have CFMX.
<cfscript>
// Create the transformer factory.
transformerFactory = createObject("java", "javax.xml.transform.TransformerFactory");
factory = transformerFactory.newInstance();
// XML document
xmlDoc = createObject("java", "javax.xml.transform.stream.StreamSource");
// Set the path to the XML document
xmlDoc.setSystemId("c:\inetpub\wwwroot\msol\msol\projecttracker\layout\list.xml");
// XSLT document
xsltDoc = createObject("java", "javax.xml.transform.stream.StreamSource");
// Set the path to the XSLT document
xsltDoc.setSystemId("c:\inetpub\wwwroot\msol\msol\projecttracker\layout\menu.xsl");
// Create the transformer.
transformer = factory.newTransformer(xsltDoc);
// Output string
result = createObject("java", "java.io.StringWriter");
// We need to do this so that the StringWriter object is actually created.
result.write("");
// Create the StreamResult
streamResult = createObject("java", "javax.xml.transform.stream.StreamResult");
// Pass the StringWriter to the StreamResult
streamResult.setWriter(result);
// Transform the XML document.
transformer.transform(xmlDoc, streamResult);
// Write it to the screen. You can do this anytime.
writeOutput(result.toString());
</cfscript>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4