大家!
我建立基于某些XML数据文件的网站,所以我选择用XSLT工作的样式表绑定的浏览器。
它的工作原理相当不错,在第一,但最近,作为模板变得更加复杂,奇怪的事情发生。
我用的是“复制的”元素将数据复制到样式表。 下面的代码:
<div class="section1">
<xsl:copy-of select="article/bodydata/*" />
</div>
所以,基本上,我复制“bodydata”节点的所有子元素为<DIV />。
但是,这是行不通的。 例如,我有在bodydata一个<img />元素,如果我访问的XML文件中的浏览器,图像不会出现。 在另一方面,如果我用手工复制“bodydata”元素融入到该分区,使的.xsl文件转换为HTML文件,该图像确实显示出来。
所以,这里是我的问题,我可以查看XML数据的组合输出,并在浏览器中的XSL数据? 我需要的任何扩展还是什么?
和什么有什么建议可能是错的? 我是很新的XSLT,这样看来,我误解了XSLT确实。 谢谢!
UPDATE
为了说明这个问题,我写了一个小样本。
首先,我创建了一个示例XML数据文件:
<?xml version='1.0' encoding='utf-8'?>
<?xml-stylesheet type="text/xsl" href="article.xsl"?>
<article>
<bodydata>
<center>
<img alt="sample" src="http://www.google.com/logos/classicplus.png" />
</center>
<p>
<data class="tts_data">
this is the paragraph.
</data>
</p>
<p>
<data class="tts_data">this is the second paragraph</data>
<data class="tts_data">more data</data>
<data class="tts_data">...</data>
</p>
</bodydata>
</article>
所以,你可以看到,在“bodydata”元素中的所有节点都需要被展示在网页的HTML元素。 为了显示这一点,我创建了一个示例的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 xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex" />
</head>
<body>
<article>
<header>
header of the article
</header>
<section>
<xsl:copy-of select="article/bodydata/*" />
</section>
</article>
<footer>
footer part of the page
</footer>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
其结果是这样的: img元素就会消失。
而接下来,我复制了bodydata元素融入节的一部分,并形成了新的HTML文件。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex" />
</head>
<body>
<article>
<header>
header of the article
</header>
<section>
<center>
<img alt="sample" src="http://www.google.com/logos/classicplus.png" />
</center>
<p>
<data class="tts_data">
this is the paragraph.
</data>
</p>
<p>
<data class="tts_data">
this is the second paragraph,
</data>
<data class="tts_data">
more data
</data>
<data class="tts_data">...</data>
</p>
</section>
</article>
<footer>
footer part of the page
</footer>
</body>
</html>
这里的结果是: 并显示图像。
所以我不知道什么是错在这里。