XML : Cannot select value using keyid in XML and XSLT

I have a problem showing the value in the table by using keyid. It shows false instead of the value that I wanted.The information that is found in these codes are just randomly generated.
This is my XML

   <?xml version="1.0" encoding="UTF-8"?>          <unit>          <assessment_details>              <assessment_item> idkey="1"                  <type>Assignment 1</type>                  <desc>Introductory HTML/XML/XSLT website</desc>                  <assess_value>20</assess_value>              </assessment_item> idkey="2"              <assessment_item>                  <type>Assignment 2</type>                  <desc>Advanced XMl/XSLT web application</desc>                  <assess_value>30</assess_value>                           </assessment_item>              <assessment_item> idkey="3"                  <type>Examination</type>                  <desc>End of semester examination</desc>                  <assess_value>50</assess_value>              </assessment_item>          </assessment_details>          <student>            <student_id>16390227</student_id>            <sname>Battle</sname>            <fname>Gillian</fname>            <results>                  <stu_mark resultkeyid="1">12</stu_mark>                  <stu_mark resultkeyid="2">25</stu_mark>                  <stu_mark resultkeyid="3">30</stu_mark>                </results>            <final_mark> </final_mark>            <final_grade> </final_grade>          </student>      </unit>    

This is my XSLT

  <?xml version="1.0" encoding="ISO-8859-1"?>  <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <xsl:template match="/">  <html>  <body>     <h2>Student Results</h2>       <table>       <tr>         <th>Student ID</th>         <th>Surname</th>         <th>Firstname</th>         <th>Assign1</th>         <th>Assign2</th>         <th>Exam</th>         <th>Final Mark</th>         <th>Final Grade</th>       </tr>         <xsl:for-each select="unit/student">       <tr>        <td><xsl:value-of select="student_id"/></td>        <td><xsl:value-of select="sname"/></td>        <td><xsl:value-of select="fname"/></td>        <td><xsl:value-of select="resultkeyid='1'"/></td>        <td><xsl:value-of select="resultkeyid='2'"/></td>        <td><xsl:value-of select="resultkeyid='3'"/></td>        <td><xsl:value-of select="final_mark"/></td>        <td><xsl:value-of select="final_grade"/></td>       </tr>       </xsl:for-each>     </table>   </body>   </html>  </xsl:template></xsl:stylesheet>    

In the table, the values in assign1, assign2, and exam is 'false' instead of 12,25,30.

No comments:

Post a Comment