0
<?xml version = "1.0" encoding = "UTF-8"?>
<?xml-stylesheet type="text/xsl" href="student-stylesheet.xsl"?>
<students>
    <student student-number = "1625344">
        <program> BIT </program>
        <study-model> on-campus </study-model>
        <student-type> domestic </student-type>
    </student>
    <student student-number = "2341235">
        <program> MIT </program>
        <study-model> distance </study-model>
        <student-type> international </student-type>
    </student>
    <student student-number = "1234567">
        <program> BMM </program>
        <study-model> on-campus </study-model>
        <student-type> domestic </student-type>
    </student>
    <student student-number = "8899009">
        <program> MIT </program>
        <study-model> on-campus </study-model>
        <student-type> domestic </student-type>
    </student>
    <student student-number = "0987654">
        <program> BIT </program>
        <study-model> on-campus </study-model>
        <student-type> domestic </student-type>
    </student>
</students>

一番下の学生番号を選択して、学生番号、プログラム、研究モデル、および学生タイプのみを含む、ヘッダーのない表として表示しようとしています。

    <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Program</th>
        <th>Student Model</th>
        <th>Student Type</th>
      </tr>
      <tr>
        <td><xsl:value-of select="students/student/program"/></td>
        <td><xsl:value-of select="students/student/study-model"/></td>
        <td><xsl:value-of select="students/student/student-type"/></td>
      </tr>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

これは私の現在のスタイルシートです。最後の生徒ではなく最初の生徒が選択され、生徒番号もありません

4

1 に答える 1

1

学生番号を取得するには、新しい TD を として入力する必要があります<td><xsl:value-of select="students/student/@student-number"/></td>。そして、最後の学生の情報だけを取得したい場合は、次のような述語を使用する必要があります <xsl:value-of select="students/student[last()]/@student-number"/>

于 2013-07-10T04:48:00.793 に答える