我有一个来自DBPedia的XML文件,它具有以下布局:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="example.xsl"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd">
<head>
<variable name="manufacturer"/>
<variable name="name"/>
<variable name="car"/>
</head>
<results distinct="false" ordered="true">
<result>
<binding name="manufacturer"><literal xml:lang="en">Ford Motor Company</literal></binding>
<binding name="name"><literal xml:lang="en">Lincoln Mark VIII</literal></binding>
<binding name="car"><uri>http://dbpedia.org/resource/Lincoln_Mark_VIII</uri></binding>
</result>
<result>
<binding name="manufacturer"><literal xml:lang="en">Ford Motor Company</literal></binding>
<binding name="name"><literal xml:lang="en">Lincoln Continental Mark VI</literal></binding>
<binding name="car"><uri>http://dbpedia.org/resource/Lincoln_Continental_Mark_VI</uri></binding>
</result>
</results>
</sparql>
这是我的XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sp="http://www.w3.org/2005/sparql-results#"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="sp:sparql">
<html>
<head><title>XSLT demo</title>
</head>
<body>
<table border="1">
<tr>
<th>Manufacturer</th>
<th>Model</th>
</tr>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="sp:result">
<tr>
<td><xsl:value-of select="sp:binding[@name='manufacturer']"/></td>
<xsl:variable name="NAME"><xsl:value-of select="sp:binding[@name='car']"/></xsl:variable>
<td><a href="{$NAME}"><xsl:value-of select="sp:binding[@name='name']"/> </a></td>
</tr>
</xsl:template>
</xsl:stylesheet>
如何使用Javascript或任何其他方式使此表可排序?我已经尝试过sorttable.js和TableSorter,但它们似乎没有用。有任何想法吗?提前谢谢!