B
bjam
Help! The apply-templates function is not currently allowing me to
select a specific template... eventhough I tried putting a select
statement, it does not seem to work??? Can someone help show how I can
select the first template and then have it select others? Below is a
sample of the xml as well as the .xsl file when
I do something like the following in the main section it does not seem
to work, it only works when I remove the select statement, and even
then it seems to only be using the first template... any help is
greatly appreciated...
<xsl:apply-templates select="hashref/item[starts-with(@key,'TEST_')]"
/>
XSL file
--------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<basefont face="Verdana" size="2" />
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:key name="key-search" match="item" use="@key" />
<xsl:template match="hashref/item[starts-with(@key,'TEST_')]">
<table border="0" bgcolor="gray">
<tr>
<th colspan="2" bgcolor="navy"><font color="white"><xsl:value-of
select="@key"/></font></th>
</tr>
<!-- output all text/control tag items -->
<xsl:for-each select="hashref/item">
<xsl:if test="text()">
<tr>
<th align="left"><xsl:value-of select="@key"/></th>
<td><font face="verdana" size="2" color="white"><xsl:value-of
select="text()"/></font></td>
</tr>
</xsl:if>
</xsl:for-each>
<!-- test results -->
<tr>
<th align="left">test result</th>
<xsl:variable name="key_value"
select="key('key-search','hypothesis_test_results')"/>
<xsl:choose>
<xsl:when test="$key_value = 'false'">
<td><font face="verdana" size="2" color="red"><xsl:value-of
select="."/></font></td>
</xsl:when>
<xsltherwise>
<td><font face="verdana" size="2" color="white"><xsl:value-of
select="."/></font></td>
</xsltherwise>
</xsl:choose>
</tr>
<xsl:apply-templates select="item[@key='hypothesis_test_results']"/>
</table>
<!-- for spacing purposes between tests -->
<table border="0"><tr><td></td></tr><tr><td></td></tr></table>
</xsl:template>
<xsl:template match="item[@key='hypothesis_test_results']">
<tr>
<td><font face="verdana" size="2" color="red"><xsl:value-of
select="test"/></font></td>
<td><font face="verdana" size="2" color="red"><xsl:value-of
select="."/></font></td>
</tr>
</xsl:template>
<!--
<xsl:apply-templates select = 'item'/>
<xsl:template match="/item[@key='hypothesis_result']" >
<tr>
<th align="left"><xsl:value-of select="@key"/></th>
<td><font face="verdana" size="2" color="blue"><xsl:value-of
select="."/></font></td>
</tr>
</xsl:template>
-->
</xsl:stylesheet>
XML file
--------------
<item key="TEST_5">
<hashref memory_address="0x943c6f4">
<item key="AccountID">58279</item>
<item key="ScheduleID">7</item>
<item key="ShortName">RBCNUK-0855-CEFL</item>
<item key="hypothesis_results">
<arrayref memory_address="0x943809c">
<item key="0">
<arrayref memory_address="0x943778c">
<item key="0">
<arrayref memory_address="0x9437744">
<item key="0">4166</item>
</arrayref>
</item>
</arrayref>
</item>
</arrayref>
</item>
<item key="hypothesis_test_results">
<hashref memory_address="0x943c6ac">
<item key="result">true</item>
</hashref>
</item>
<item key="sample_results">
<arrayref memory_address="0x943259c">
<item key="0">
<arrayref memory_address="0x9432614">
<item key="0">
<arrayref memory_address="0x94381bc">
<item key="0">4160</item>
</arrayref>
</item>
<item key="1">
<arrayref memory_address="0x943241c">
<item key="0">4153</item>
</arrayref>
</item>
<item key="2">
<arrayref memory_address="0x9432638">
<item key="0">4162</item>
</arrayref>
</item>
<item key="3">
<arrayref memory_address="0x94380fc">
<item key="0">4164</item>
</arrayref>
</item>
<item key="4">
<arrayref memory_address="0x94381b0">
<item key="0">4163</item>
</arrayref>
</item>
<item key="5">
<arrayref memory_address="0x94380cc">
<item key="0">4165</item>
</arrayref>
</item>
<item key="6">
<arrayref memory_address="0x94381d4">
<item key="0">4168</item>
</arrayref>
</item>
</arrayref>
</item>
</arrayref>
</item>
<item key="stats_results">
<hashref memory_address="0x943376c">
<item key="MEAN">4162.14285714286</item>
<item key="STD">4.74090608177306</item>
<item key="STD_ERROR">1.79189406878359</item>
<item key="confidence_interval_lower">4151</item>
<item key="confidence_interval_upper">4173</item>
<item key="critical_value">5.9565</item>
<item key="degrees_of_freedom">6</item>
<item key="distribution">tdistr</item>
<item key="interval_type">integer</item>
<item key="level_of_significance">0.000499999999999972</item>
<item key="sample_size">7</item>
<item key="type_of_test">two tailed test</item>
</hashref>
</item>
</hashref>
</item>
select a specific template... eventhough I tried putting a select
statement, it does not seem to work??? Can someone help show how I can
select the first template and then have it select others? Below is a
sample of the xml as well as the .xsl file when
I do something like the following in the main section it does not seem
to work, it only works when I remove the select statement, and even
then it seems to only be using the first template... any help is
greatly appreciated...
<xsl:apply-templates select="hashref/item[starts-with(@key,'TEST_')]"
/>
XSL file
--------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<basefont face="Verdana" size="2" />
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:key name="key-search" match="item" use="@key" />
<xsl:template match="hashref/item[starts-with(@key,'TEST_')]">
<table border="0" bgcolor="gray">
<tr>
<th colspan="2" bgcolor="navy"><font color="white"><xsl:value-of
select="@key"/></font></th>
</tr>
<!-- output all text/control tag items -->
<xsl:for-each select="hashref/item">
<xsl:if test="text()">
<tr>
<th align="left"><xsl:value-of select="@key"/></th>
<td><font face="verdana" size="2" color="white"><xsl:value-of
select="text()"/></font></td>
</tr>
</xsl:if>
</xsl:for-each>
<!-- test results -->
<tr>
<th align="left">test result</th>
<xsl:variable name="key_value"
select="key('key-search','hypothesis_test_results')"/>
<xsl:choose>
<xsl:when test="$key_value = 'false'">
<td><font face="verdana" size="2" color="red"><xsl:value-of
select="."/></font></td>
</xsl:when>
<xsltherwise>
<td><font face="verdana" size="2" color="white"><xsl:value-of
select="."/></font></td>
</xsltherwise>
</xsl:choose>
</tr>
<xsl:apply-templates select="item[@key='hypothesis_test_results']"/>
</table>
<!-- for spacing purposes between tests -->
<table border="0"><tr><td></td></tr><tr><td></td></tr></table>
</xsl:template>
<xsl:template match="item[@key='hypothesis_test_results']">
<tr>
<td><font face="verdana" size="2" color="red"><xsl:value-of
select="test"/></font></td>
<td><font face="verdana" size="2" color="red"><xsl:value-of
select="."/></font></td>
</tr>
</xsl:template>
<!--
<xsl:apply-templates select = 'item'/>
<xsl:template match="/item[@key='hypothesis_result']" >
<tr>
<th align="left"><xsl:value-of select="@key"/></th>
<td><font face="verdana" size="2" color="blue"><xsl:value-of
select="."/></font></td>
</tr>
</xsl:template>
-->
</xsl:stylesheet>
XML file
--------------
<item key="TEST_5">
<hashref memory_address="0x943c6f4">
<item key="AccountID">58279</item>
<item key="ScheduleID">7</item>
<item key="ShortName">RBCNUK-0855-CEFL</item>
<item key="hypothesis_results">
<arrayref memory_address="0x943809c">
<item key="0">
<arrayref memory_address="0x943778c">
<item key="0">
<arrayref memory_address="0x9437744">
<item key="0">4166</item>
</arrayref>
</item>
</arrayref>
</item>
</arrayref>
</item>
<item key="hypothesis_test_results">
<hashref memory_address="0x943c6ac">
<item key="result">true</item>
</hashref>
</item>
<item key="sample_results">
<arrayref memory_address="0x943259c">
<item key="0">
<arrayref memory_address="0x9432614">
<item key="0">
<arrayref memory_address="0x94381bc">
<item key="0">4160</item>
</arrayref>
</item>
<item key="1">
<arrayref memory_address="0x943241c">
<item key="0">4153</item>
</arrayref>
</item>
<item key="2">
<arrayref memory_address="0x9432638">
<item key="0">4162</item>
</arrayref>
</item>
<item key="3">
<arrayref memory_address="0x94380fc">
<item key="0">4164</item>
</arrayref>
</item>
<item key="4">
<arrayref memory_address="0x94381b0">
<item key="0">4163</item>
</arrayref>
</item>
<item key="5">
<arrayref memory_address="0x94380cc">
<item key="0">4165</item>
</arrayref>
</item>
<item key="6">
<arrayref memory_address="0x94381d4">
<item key="0">4168</item>
</arrayref>
</item>
</arrayref>
</item>
</arrayref>
</item>
<item key="stats_results">
<hashref memory_address="0x943376c">
<item key="MEAN">4162.14285714286</item>
<item key="STD">4.74090608177306</item>
<item key="STD_ERROR">1.79189406878359</item>
<item key="confidence_interval_lower">4151</item>
<item key="confidence_interval_upper">4173</item>
<item key="critical_value">5.9565</item>
<item key="degrees_of_freedom">6</item>
<item key="distribution">tdistr</item>
<item key="interval_type">integer</item>
<item key="level_of_significance">0.000499999999999972</item>
<item key="sample_size">7</item>
<item key="type_of_test">two tailed test</item>
</hashref>
</item>
</hashref>
</item>