【发布时间】:2015-11-01 08:04:42
【问题描述】:
我正在尝试将我的 XSL 链接到我的 XML,但是当我在 Chrome 或其他网络浏览器中加载 XML 页面时,我得到一个空白页面。
我不确定它到底出了什么问题。
下面是我的 XML
<?xml-stylesheet type="text/xsl" href="vaults.xsl"?>
<vaults xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vaults.xsd">
<vault>
<vaultname>Los Angeles Vault </vaultname>
<state>California</state>
<location>Los Angeles (Cathedral)</location>
<description>The Vault-Tec demonstration vault. It was not part of the experiment, and was the Master's vault under the Cathedral. </description>
<fate> </fate>
<appearance>Fallout</appearance>
</vault>
</vaults>
以下是XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Vaults</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">vault</th>
</tr>
<xsl:for-each select="vaults/vault">
<tr>
<td><xsl:value-of select="vaultname" /></td>
<td><xsl:value-of select="state" /></td>
<td><xsl:value-of select="location" /></td>
<td><xsl:value-of select="description" /></td>
<td><xsl:value-of select="fate" /></td>
<td><xsl:value-of select="appearance" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
【问题讨论】: