XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 15th, 2013, 08:38 PM
Man_Hunt Man_Hunt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 Man_Hunt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 12 sec
Reputation Power: 0
XSLT passing two parameters in URL with ColdFusion

I am trying to pass two parameters through URL in XSLT file by using ColdFusion.

This is my XSLT code:

Code:
<xsl:template match="/">
    <xsl:text>Actors: </xsl:text>
    <xsl:apply-templates select="/movies/movie/actors/actor/name"/>
</xsl:template>

<xsl:template match="name">
      <xsl:element name="a">
          <xsl:attribute name="href">actor_details.cfm?movieID=<xsl:value-of select="../../../@movieID"/>&actorID=<xsl:value-of select="../@actorID"/></xsl:attribute>
          <xsl:value-of select="." />
      </xsl:element>
      <xsl:element name="br" />
</xsl:template>


This is my actor_details.cfm file

Code:
<cfset MyXmlFile = Expandpath("test.xml")>
<cffile action="READ" variable="xmlInput"  file="#MyXmlFile#">
<cfset MyXslFile = Expandpath("actor_details.xsl")>
<cffile action="READ" variable="xslInput"  file="#MyXslFile#">

<cfset xslParam = StructNew() >
<cfset xslParam["movieID"] = "#url.movieID#" >

<cfset xmlOutput = XMLTransform(xmlInput, xslInput, xslParam )>
<!--- data is output --->
<cfcontent type="text/html" reset="yes">
<cfoutput>#xmloutput#</cfoutput>


And this is my actor_details.xsl file

Code:
<xsl:param name="movieID"/>

<xsl:template match="/">
    <title>Actor details</title>
    <xsl:apply-templates select="/movies/movie[@movieID=$movieID]/actors/actor[@actorID=$actorID]"/>
</xsl:template>

<xsl:template match="actor">
    <xsl:text>Name: </xsl:text>
    <xsl:value-of select="name"/>
    <xsl:element name="br"/>
    <xsl:text>Age: </xsl:text>
    <xsl:value-of select="age"/>
    <xsl:element name="br"/>
</xsl:template>


So based on the movieID and actorID passed through the URL, the actor_details page should display the actor's name and age. I am very new to ColdFusion and I can't figure out how to receive parameters passed through the URL with ColdFusion. I get unexpected error on the actor_details.cfm page.

I think the problem lies somewhere in actor_details.cfm page, but I just can't figure out what it is.

My XML file:

Code:
<movie movieID="1">
    <actors>
        <actor actorID="1"> 
            <name>Bob</name>
            <age>23</age>
        </actor>

        <actor actorID="2"> 
            <name>Jack</name> 
            <age>25</age>
        </actor>

        <actor actorID="3"> 
            <name>James</name>
            <age>38</age>
        </actor>
    </actors>   
</movie>

<movie movieID="2">
    <actors>
        <actor actorID="1"> 
            <name>Mike</name>
            <age>19</age>
        </actor>

        <actor actorID="2"> 
            <name>Daniel</name>
            <age>29</age>
        </actor>

        <actor actorID="3"> 
            <name>Phil</name> 
            <age>41</age>
        </actor>
    </actors>   
</movie>

Reply With Quote
  #2  
Old March 16th, 2013, 08:19 AM
Man_Hunt Man_Hunt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 Man_Hunt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 12 sec
Reputation Power: 0
I have fixed the problem by adding
Code:
<cfset xslParam["actorID"] = "#url.actorID#" > 
to my CFM file and
Code:
<xsl:param name="actorID"/>
to my XSL file.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSLT passing two parameters in URL with ColdFusion

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap