• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XML to XSL

Contributor ,
Aug 20, 2012 Aug 20, 2012

Copy link to clipboard

Copied

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

Views

566

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 20, 2012 Aug 20, 2012

Copy link to clipboard

Copied

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.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

LATEST

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">

        <eventid>1111</eventid>

        <eventname>test april 18</eventname>

        <submitdate>04/18/20</submitdate>

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

        <eventstatus>Report delivered</eventstatus>

        <contacts>

           <contactsrow>

                <role>xxxxxxxx</role>

                <firstname>xxxx</firstname>

                <lastname>Toxxx</lastname>

            </contactsrow>

            <contactsrow>

                <role>xxxx</role>

                <firstname>Exxxxric</firstname>

                <lastname>xx</lastname>

            </contactsrow>

        </contacts>

    </event>

</events>

<cfsavecontent>

<cfsavecontent variable="xsldoc">

<cfoutput>   

<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="/">

        <html>

            <body>

                <table border="1">

                    <tr>

                        <td>Event Name</td>

                        <td>

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

                        </td>

                    </tr>

                    <tr>

                        <td>Date Submitted</td>

                        <td>

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

                        </td>

                    </tr>

                    <tr>

                        <td>Event Status</td>

                        <td>

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

                        </td>

                    </tr>

                    <!---

                    <xsl:for-each select="">

                        <tr>

                            <td>

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

                            </td>

                            <td>

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

                            </td>

                        </tr>

                    </xsl:for-each>

                    --->

                </table>

            </body>

        </html>

    </xsl:template>

</xsl:stylesheet>

</cfoutput>

</cfsavecontent>

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation