XML中是可以使用XSLT的,实例如下。但是打开appUsersWithXslt.xml这个文件不一定会有如下正常的显示。
这是为什么呢?
查询资料后,发现有些内核不再支持XSLT,如极速内核。有些内核支持XSLT,如IE内核。
IE浏览器是可以打开appUsersWithXslt.xml,有正常的显示的。(亲测 IE9 可用)
360浏览器和QQ浏览器在退出极速模式并切换为IE内核后 也可以打开appUsersWithXslt.xml,有正常的显示的。他们在极速模式下是无法正常显示appUsersWithXslt.xml的。
appUsersWithXslt.xml:
<?xml-stylesheet type="text/xsl" href="appUsers.xslt" ?>
<applicationUsers>
<user firstName="Joe" lastName="Fawcett" />
<user firstName="Danny" lastName="Ayers" />
<user firstName="Catherine" lastName="Middleton" />
</applicationUsers>
appUsers.xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Application Users</title>
</head>
<body>
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="applicationUsers/user" />
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="user">
<tr>
<td>
<xsl:value-of select="@firstName"/>
</td>
<td>
<xsl:value-of select="@lastName"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
XSLT兼容性不好,在一些老的项目中使用较多,新项目很少会使用它!!!