使用 XSL 进行解析
Firefox 出现以下错误: 加载样式表时出错:解析 XSLT 样式表失败。
在 Google Chrome 中,它显示一个空白页面。
这是我的 .xsl 的代码
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Curriculum Vitae</title>
<link rel="stylesheet" type="text/css" href="css/myStyle.css"/>
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
<h1>Curriculum Vitae: Matthew Stanley Klein</h1>
<br/>
<ul id="nav">
<li><a href="#">General Information</a></li>
<li><a href="#">Work Experience</a></li>
<li><a href="#">Miscellaneous</a></li>
<li><a href="#">References</a></li>
<li><a href="#">Showreel</a></li>
</ul>
<xsl:for-each select="references/company">
<xsl:choose>
<xsl:when test="name != ''">
<dl>
<dt><xsl:value-of select="name" /></dt>
<dd>
<dl>
<dt>Name of Person: <xsl:value-of select="person" /></dt>
<dd>
<xsl:when test="cellphone != ''">
Cellphone: <xsl:value-of select="cellphone" />
</xsl:when>
<xsl:when test="work != ''">
<br/>
work: <xsl:value-of select="work" />
</xsl:when>
<xsl:when test="email != ''">
<br/>
email: <xsl:value-of select="email" />
</xsl:when>
</dd>
</dl>
</dd>
</dl>
</xsl:when>
<hr/>
</xsl:choose>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
是什么导致了此错误?
Firefox gives the following error:
Error loading stylesheet: Parsing an XSLT stylesheet failed.
In Google Chrome it shows a blank page.
Here is the code for my .xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Curriculum Vitae</title>
<link rel="stylesheet" type="text/css" href="css/myStyle.css"/>
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
<h1>Curriculum Vitae: Matthew Stanley Klein</h1>
<br/>
<ul id="nav">
<li><a href="#">General Information</a></li>
<li><a href="#">Work Experience</a></li>
<li><a href="#">Miscellaneous</a></li>
<li><a href="#">References</a></li>
<li><a href="#">Showreel</a></li>
</ul>
<xsl:for-each select="references/company">
<xsl:choose>
<xsl:when test="name != ''">
<dl>
<dt><xsl:value-of select="name" /></dt>
<dd>
<dl>
<dt>Name of Person: <xsl:value-of select="person" /></dt>
<dd>
<xsl:when test="cellphone != ''">
Cellphone: <xsl:value-of select="cellphone" />
</xsl:when>
<xsl:when test="work != ''">
<br/>
work: <xsl:value-of select="work" />
</xsl:when>
<xsl:when test="email != ''">
<br/>
email: <xsl:value-of select="email" />
</xsl:when>
</dd>
</dl>
</dd>
</dl>
</xsl:when>
<hr/>
</xsl:choose>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
What is causing this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
xsl:when
父级应该是xsl:choose
。xsl:choose
应仅包含xsl:when
(而不是
)xsl:when
parent should bexsl:choose
.xsl:choose
should contain onlyxsl:when
(not<hr/>
)xsl:when
必须是xsl:choose
的子级,而不是,并且
xsl:choose
可以仅将xsl:when
和xsl:otherwise
作为子项,而不是<\hr>
。您可以使用 VisualStudio Express 和 Eclipse XML 包作为 XSLT 编辑器来在编写这些内容时查找这些内容。
xsl:when
must be child ofxsl:choose
, not<dd>
, andxsl:choose
can only havexsl:when
andxsl:otherwise
as children, not<\hr>
.You can use VisualStudio Express and Eclipse XML package as XSLT editors to find these things while you write them.
也许是
和
之间的
?它应该位于
内,或位于
之外...Maybe it's the
<hr/>
between</xsl:when>
and</xsl:choose>
?It should be either within
<xsl:when>
, or outside<xsl:choose>
...编写 XSLT 时使用 XML Spy 或类似工具 - 该工具会快速告诉您什么是允许的,什么是不允许的。
Use XML Spy or similar tools when writing XSLT - the tool will quickly tell you what is and what is not allowed.