页面上不会加载XML和XSLT文件请帮忙 [英] XML and XSLT files won't load on page please help
本文介绍了页面上不会加载XML和XSLT文件请帮忙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个XML和XSL文件,以HTML格式加载到网页上。由于某种原因,这不起作用..数据没有显示在网页浏览器的表格中。
这是我的代码如下,有什么我失踪了?请帮忙?
XML文件
<? xml version = 1.0 ? >
<? xml-stylesheet < span class =code-summarycomment> href = skymovies.xsl type = text / xsl ? >
< 集合 >
< 电影 >
< title > Happy Gilmore < / title >
< < span class =code-leadattribute> year > 1991 < / year >
< < span class =code-leadattribute>流派 > 喜剧< / genre >
< / film >
< 电影 >
< title > Rango < / title >
< 年 > 1991 < / year >
< 流派 > 喜剧< / genre >
< / film >
< 电影 >
< title > Happy Gilmore < / title >
< year > 1991 < / year >
< genre > 喜剧< / genre >
< / film >
< / movie >
< / collection >
XSLT文件
< ; xml version = 1.0 编码 = IS0-8859-1 ? >
< xsl:stylesheet version = 1.0
xmlns:xsl = http://www.w3.org/1999/XSL/Transform >
< xsl:template 匹配 = /集合 >
< html >
< body >
< table border = 1 >
< tr >
< th > 标题 < / th >
< th > 年< / th >
< th > 类型< / th >
< / tr >
< xsl:for-each 选择 = 电影 >
< xsl:value-of 选择 = title / > < / td >
< xsl:value-of 选择 = 年 / > < / td >
< xsl:value-of 选择 = 类型 / > < / td >
< / xsl:for-each > ;
< / table >
< / body >
< / html >
< / xsl:template >
< / xsl:stylesheet >
有没有我做错了?请帮忙?
解决方案
您的编码有问题,您使用零而不是'O'
使用以下:
<? xml version = 1.0 encoding = ISO-8859-1 ? >
< xsl:stylesheet version = 1.0
xmlns:xsl = http://www.w3.org/1999/XSL/转换 >
< xsl:template 匹配 = / collection >
< html >
< body >
< 表 边界 = 1 < span class =code-keyword>>
< tr >
< th > 标题< / th >
< th > 年< / th >
< th > 类型< / th >
< / tr >
< xsl:for-each 选择 = 电影 >
< tr >
< td > < xsl:value-of 选择 = title / > < / td >
< td > < xsl:value-of 选择 < span class =code-keyword> = year / > < / td >
< td > < xsl:value-of 选择 = 流派 / > < / td >
< / tr >
< / xsl :for-each >
< / table >
< / body >
< / html >
< / xsl:template >
< / xsl:stylesheet >
另外,你有一个孤儿< / movie>标签
I have created an XML and XSL file to be loaded onto a webpage as HTML. for some reason this is not working .. the data isn't being displayed in a table on to a web browser.
Here is my code below, is there anything that i am missing? please help?
XML file
<?xml version="1.0"?>
<?xml-stylesheet href="skymovies.xsl" type="text/xsl"?>
<collection>
<film>
<title>Happy Gilmore</title>
<year>1991</year>
<genre>Comedy</genre>
</film>
<film>
<title>Rango</title>
<year>1991</year>
<genre>Comedy</genre>
</film>
<film>
<title>Happy Gilmore</title>
<year>1991</year>
<genre>Comedy</genre>
</film>
</movie>
</collection>
XSLT File
<?xml version="1.0" encoding="IS0-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/collection">
<html>
<body>
<table border="1">
<tr>
<th>Title</th>
<th>Year</th>
<th>Genre</th>
</tr>
<xsl:for-each select="film">
<xsl:value-of select="title" /></td>
<xsl:value-of select="year" /></td>
<xsl:value-of select="genre" /></td>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Is there anythig i'm doing wrong? please help?
解决方案
There is something wrong with your encoding, you're using a zero instead of an 'O'
Use the following:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/collection"> <html> <body> <table border="1" > <tr> <th>Title</th> <th>Year</th> <th>Genre</th> </tr> <xsl:for-each select="film"> <tr> <td><xsl:value-of select="title" /></td> <td><xsl:value-of select="year" /></td> <td><xsl:value-of select="genre" /></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Also, you have an orphaned </movie> tag
这篇关于页面上不会加载XML和XSLT文件请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文