2013-07-10 62 views
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> 

我试图选择底部的学生号码,并显示为一个没有标题,只包含学号,程序,学习模式和学生类型的表。选择使用XSL样式表

<?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> 

这是我目前sylesheet,它选择的第一个学生,不是最后一个,也缺少学生人数

+0

XLS不是XSL。不要混淆。 – Raptor

回答

1

为了让学生数量,你应该把新的TD作为<td><xsl:value-of select="students/student/@student-number"/></td>。如果你只想得到最后一个学生的信息,你应该使用谓词<xsl:value-of select="students/student[last()]/@student-number"/>

+0

当我输入上述内容时,它会呈现为空白的白色屏幕,因此不会选择任何内容 –