Coldfusion Paths and XSLT

Discussion in 'Programming' started by keyri88, Dec 24, 2009.

  1. #1
    Hey I'm using cold-fusion to take a .XML file and mix it with a .XSL file
    My code is currently like this -

    
    <!--- transform.cfm --->
    <cfset MyXmlFile = Expandpath("http://www.celticquicknews.co.uk/rss.xml")>
    <cffile action="READ" variable="xmlInput"  file="#MyXmlFile#">
    <cfset MyXmlFile = Expandpath("Stylesheets/celtrss.xsl")>
    <cffile action="READ" variable="xslInput" file="#MyXmlFile#">
    <cfset xmlOutput = XMLTransform(xmlInput, xslInput)>
    <!--- data is output --->
    <cfcontent type="text/html" reset="yes">
    <cfoutput>#xmloutput#</cfoutput>
    <cfinclude template="menu.html">
    
    Code (markup):
    If I use line 2 as is it does not work. But if I rip the rss.xml of the same site and save it as my own XML file and refer to it directly it works perfectly. Any idea why the internet link to the .XML file won't work?
     
    keyri88, Dec 24, 2009 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What does "doesn't work" mean? Do you get an error...?

    Without knowing more, it looks like you're using both Expandpath() and CFFILE incorrectly. CFFILE reads files on _your_ local server. To read a url of a remote server you need to use CFHTTP.

    Also, ExpandPath() it is intended for use with a relative path on your server. For example, it can convert the shortcut for root "/" to a physical path like "C:\ColdFusion8\wwwrooot"
     
    cfStarlight, Dec 28, 2009 IP
  3. keyri88

    keyri88 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey CFStarlight I was just getting a blank screen with the original but after your reply I looked up what you said and found how to sort it out.

    I changed it to
    <CFHTTP METHOD="GET" URL="http://www.celticquicknews.com/rss.xml">
    <CFSET xmlInput = CFHTTP.FileContent>


    Which works now so thanks for helping me out!
     
    keyri88, Jan 1, 2010 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Good job! (extra characters because posts must be 10 chars min..)
     
    cfStarlight, Jan 14, 2010 IP