Hi!
I’ve got one stylesheet (Room.xsl) with the template “Room” and another (Components.xsl) with the template “Components”. Now I try to call the template “Components” from the template “Room” and I want to use a param called “componentID” in the template “Components”.
What is wrong here?
This is the xml:
<?xml version="1.0"?>
<house>
<room_list>
<room ID="1">
<name>kitchen</name>
<component-ID-list>
<componentID>12</componentID>
<componentID>13</componentID>
<componentID>14</componentID>
<componentID>15</componentID>
</component-ID-list>
</room>
<room ID="2">
<name>floor</name>
<component-ID-list>
<componentID>10</componentID>
<componentID>15</componentID>
<componentID>11</componentID>
<componentID>13</componentID>
</component-ID-list>
</room>
</room_list>
<component_list>
<component ID="10">
<type>wall</type>
</component>
<component ID="11">
<type>no</type>
</component>
<component ID="12">
<type>roof</type>
</component>
<component ID="13">
<type>standard</type>
</component>
<component ID="14">
<type>wall</type>
</component>
<component ID="15">
<type>no</type>
</component>
</component_list>
</house>
</pre> <BR><BR>This is the Room.xsl:<BR> <pre class="ip-ubbcode-code-pre">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" version="1.0"/>
<xsl:include href="Component.xsl"/>
<xsl:template name="Room" match="/">
<xsl:text>Room: </xsl:text><xsl:value-of select="house/room_list/room/name"/>
<xsl:text>Components: </xsl:text>
<xsl:for-each select="house/room_list/room/component-ID-list/componentID">
<xsl:call-template name="Component">
<xsl:with-param name="componentID" select="."/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</pre> <BR><BR>Now I try to use componentID in the Components Template:<BR><BR>First way:<BR> <pre class="ip-ubbcode-code-pre">
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="Components" match="house/component_list/component[@ID='$componentID']">
<xsl:param name="componentID"/>
<xsl:text>- </xsl:text><xsl:value-of select="type"/>
</xsl:template>
</xsl:stylesheet>
</pre> <BR><BR>Second way:<BR> <pre class="ip-ubbcode-code-pre">
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="Components" match="house/component_list/component">
<xsl:param name="componentID"/>
<xsl:if test="@ID='$componentID'">
<xsl:text>- </xsl:text><xsl:value-of select="type"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Why doesn’t it work?
Greetings