2 Replies Latest reply on Aug 21, 2012 1:28 PM by umuayo

    XML to XSL

    umuayo Level 1

      I am strugling to output my xml document in an xsl format.

      My xml document is created in a function, and I have another function that takes the xml and transform it to an xsl document... something is wrong somewhere the output to xsl is not happening.


      My question is, how would I transform an XML document to an XSL. The outputs for both are created on the fly, thus the function returns the xml which I am using to create the xsl and saved in a cfsavecontent and then output to html. no files are saved to the drive

        • 1. Re: XML to XSL
          Adam Cameron. Level 5

          Can you clarify what you mean?  An XSL file is already intrinsically XML, so your question is "ambiguous" if you don't show us a before and after of the requirement, as well as the code you've been working on to try to effect the solution.


          Are you perhaps meaning you're trying to use XSL to transform XML into [whatever the XSL defines the transformation to be]?  Again, without getting a better idea of the inputs and the outputs, it's difficult to say.


          The basic form of performing an XSL transformation in CF is:


          result = smlTransform(anXmlDoc, anXslDoc);


          It doesn't matter if the XML or XSL are strings containing the XML / XSL, file paths that contain them, or anything else that returns either of those.




          • 2. Re: XML to XSL
            umuayo Level 1

            See the below files. Just to output the values of the xml to the xsl and to the page the values are not being out put and also loop through the contacts tag and outpout the values of

                            <role>Hello Chair</role><firstname>Test</firstname> <lastname>CC</lastname>

            <cfsavecontent variable="xmldoc">

            <?xml version="1.0" encoding="UTF-8"?>

            <events reportname="Report Reviews ">

                <event id="1111">


                    <eventname>test april 18</eventname>


                    <eventdate>Jan 18, 2014 - Jan 22, 2014</eventdate>

                    <eventstatus>Report delivered</eventstatus>
















            <cfsavecontent variable="xsldoc">


            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

            <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />

                <xsl:template match="/">



                            <table border="1">


                                    <td>Event Name</td>


                                        <xsl:value-of select="eventname" />




                                    <td>Date Submitted</td>


                                        <xsl:value-of select="eventdate" />




                                    <td>Event Status</td>


                                        <xsl:value-of select="eventstatus" />





                                <xsl:for-each select="">



                                            <xsl:value-of select=""/>



                                            <xsl:value-of select=""/>












            ReportData:<cfoutput>#XmlTransform(Trim(xmldoc), Trim(xmldoc))#</cfoutput>