ColdFusion を使用して、XSLT ファイルの URL を介して 2 つのパラメーターを渡そうとしています。
これは私のXSLTコードです:
<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>
これは私のactor_details.cfmファイルです
<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>
これが私のactor_details.xslファイルです
<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>
そのため、URL を介して渡された movieID とactorID に基づいて、actor_details ページに俳優の名前と年齢が表示されます。ColdFusion を初めて使用するので、ColdFusion で URL を介して渡されたパラメーターを受け取る方法がわかりません。actor_details.cfm ページで予期しないエラーが発生します。
問題はactor_details.cfmページのどこかにあると思いますが、それが何であるかわかりません。
私のXMLファイル:
<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>