在 html 页面上显示 xsl 文件
我在网页上以 xsl 形式显示 xml 文件时遇到了很多麻烦 这是网页 euroFixtures
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Fixtures</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<link href="oneColElsCtr.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColElsCtr">
<div id="header">
<h1><a href="home.html"><img src="euro2012.jpg" alt="" width="713" height="146" /></a></h1>
<div id="links" align="middle">
<table width="711" height="59" border="1">
<!-- TemplateBeginEditable name="EditRegion4" -->
<tr>
<td width="177"><a href="euroHome.html">News</a></td>
<td width="177"><a href="euroWeather.html"> Weather</a></td>
<td width="160"><a href="euroCurrency.html">Currency Converter</a></td>
<td width="169"><a href="euroFixtures.html">Fixtures</a></td>
</tr>
<!-- TemplateEndEditable -->
</table>
</div>
</div>
<div id="container">
<div id="mainContent" ><!-- TemplateBeginEditable name="hujhjhj" -->
<frameset columns="45%,55%" cols="*,*" >
<frame src="fixtures.xml" frameborder="1"/>
<frame src="frame.html" frameborder="1"/>
</frameset>
<!-- TemplateEndEditable -->
<!-- end #mainContent --></div>
<!-- end #container --></div>
</body>
</html>
这是 xml 文件装置
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="fixtures.xsl" type="text/xsl"?>
<fixtures>
<fixture>
<match>Ireland vs. Poland</match>
<date>05-06-12</date>
<ground>Apatov</ground>
<group>A</group>
</fixture>
<fixture>
<match>France vs. Germany</match>
<date>05-06-012</date>
<ground>Krakow</ground>
<group>A</group>
</fixture>
<fixture>
<match>Italy vs. Spain</match>
<date>06-06-12</date>
<ground>Kiev</ground>
<group>B</group>
</fixture>
<fixture>
<match>Portugal vs. Croatia</match>
<date>06-06-12</date>
<ground>Warsaw</ground>
<group>B</group>
</fixture>
<fixture>
<match>Austria vs. Greece</match>
<date>07-06-12</date>
<ground>Flam</ground>
<group>C</group>
</fixture>
<fixture>
<match>Lithuania vs. Latvia</match>
<date>07-06-12</date>
<ground>Gameu</ground>
<group>C</group>
</fixture>
<fixture>
<match>England vs. Sweden</match>
<date>08-06-12</date>
<ground>Hanaas</ground>
<group>D</group>
</fixture>
<fixture>
<match>Norway vs. Denmark</match>
<date>08-06-12</date>
<ground>Olam</ground>
<group>D</group>
</fixture>
</fixtures>
,这是 xsl 文件装置
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html><head> <title>Output document</title></head>
<body><xsl:apply-templates /></body></html>
</xsl:template>
<xsl:template match="fixture">
<table width="100%" border="2">
<tr bgcolor="silver"><td>match</td><td>date</td><td>ground</td><td>group</td></tr>
<xsl:for-each select="fixture">
<tr>
<td><xsl:value-of select="match"/></td>
<td><xsl:sort select="date"
order="ascending" data-type="text"/></td>
<td><xsl:value-of select="ground"/></td>
<td><xsl:value-of select="group"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
,我认为这并不重要,但这是 html 文件框架
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled 2</title>
</head>
<body>
frame_a.htm
</body>
</html>
。我一直在尝试,但我无法让这件事发挥作用。 谁能帮助我,我将不胜感激
im having a lot of trouble truing to display the my xml file in xsl form on my web page
here is the web page euroFixtures
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Fixtures</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<link href="oneColElsCtr.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColElsCtr">
<div id="header">
<h1><a href="home.html"><img src="euro2012.jpg" alt="" width="713" height="146" /></a></h1>
<div id="links" align="middle">
<table width="711" height="59" border="1">
<!-- TemplateBeginEditable name="EditRegion4" -->
<tr>
<td width="177"><a href="euroHome.html">News</a></td>
<td width="177"><a href="euroWeather.html"> Weather</a></td>
<td width="160"><a href="euroCurrency.html">Currency Converter</a></td>
<td width="169"><a href="euroFixtures.html">Fixtures</a></td>
</tr>
<!-- TemplateEndEditable -->
</table>
</div>
</div>
<div id="container">
<div id="mainContent" ><!-- TemplateBeginEditable name="hujhjhj" -->
<frameset columns="45%,55%" cols="*,*" >
<frame src="fixtures.xml" frameborder="1"/>
<frame src="frame.html" frameborder="1"/>
</frameset>
<!-- TemplateEndEditable -->
<!-- end #mainContent --></div>
<!-- end #container --></div>
</body>
</html>
here is the xml file fixtures
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="fixtures.xsl" type="text/xsl"?>
<fixtures>
<fixture>
<match>Ireland vs. Poland</match>
<date>05-06-12</date>
<ground>Apatov</ground>
<group>A</group>
</fixture>
<fixture>
<match>France vs. Germany</match>
<date>05-06-012</date>
<ground>Krakow</ground>
<group>A</group>
</fixture>
<fixture>
<match>Italy vs. Spain</match>
<date>06-06-12</date>
<ground>Kiev</ground>
<group>B</group>
</fixture>
<fixture>
<match>Portugal vs. Croatia</match>
<date>06-06-12</date>
<ground>Warsaw</ground>
<group>B</group>
</fixture>
<fixture>
<match>Austria vs. Greece</match>
<date>07-06-12</date>
<ground>Flam</ground>
<group>C</group>
</fixture>
<fixture>
<match>Lithuania vs. Latvia</match>
<date>07-06-12</date>
<ground>Gameu</ground>
<group>C</group>
</fixture>
<fixture>
<match>England vs. Sweden</match>
<date>08-06-12</date>
<ground>Hanaas</ground>
<group>D</group>
</fixture>
<fixture>
<match>Norway vs. Denmark</match>
<date>08-06-12</date>
<ground>Olam</ground>
<group>D</group>
</fixture>
</fixtures>
and here is the xsl file fixtures
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html><head> <title>Output document</title></head>
<body><xsl:apply-templates /></body></html>
</xsl:template>
<xsl:template match="fixture">
<table width="100%" border="2">
<tr bgcolor="silver"><td>match</td><td>date</td><td>ground</td><td>group</td></tr>
<xsl:for-each select="fixture">
<tr>
<td><xsl:value-of select="match"/></td>
<td><xsl:sort select="date"
order="ascending" data-type="text"/></td>
<td><xsl:value-of select="ground"/></td>
<td><xsl:value-of select="group"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
and i dont think that it is important but here is the html file frame
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled 2</title>
</head>
<body>
frame_a.htm
</body>
</html>
. i have been trying and trying but i cannot get this thing to work.
Can anyone hepl me it would be highly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码包含一个明显的语法错误:
xsl:sort
只能是xsl:for-each
的子级或xsl的子级:应用模板
。这里它是td
的子元素。还有第二个语义错误:
上面的
xsl:for-each
主体不会应用于任何节点,因为当前节点(fixture) 没有任何名为
fixture
的子项。您可能需要:
完整的更正代码为:
当应用于提供的 XML 文档时:
This code contains an obvious syntactic error:
xsl:sort
can only be child ofxsl:for-each
or child ofxsl:apply-templates
. Here it is child oftd
.There is a second, semantic error:
The body of
xsl:for-each
above will not be applied to any node, because the current node (fixture
) doesn't have any children namedfixture
.You probably want:
The complete corrected code is:
and when applied to the provided XML document: