如何在Xsl中直接引入一个Html文件哪?是否可以?

lshdic 2002-12-18 10:15:22
如果要编写几个XSL样式表,但都要有一个“导行条网页”,这个导航条网页经常更新,如果以后要更新,那么又得一个一个的去改XSL太麻烦,不知XSL如何引入一个URL页哪?或读取该URL页的数据使其变为该XSL的一部分HTML标签哪?

<?xml version='1.0' encoding='gb2312'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">

我想在这里引入一个HTML网页而不是引入XSL,
还有这个HTML网页的排版非常复杂,例如含有<hr>但没有关闭标签,含有<div align=center></div>而align=center没有加引号,这都会导致XSL不能执行呀,怎么办?

<table>
<xsl:for-each select="document/page">
<tr>
<td><xsl:value-of select="messgdates"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
...全文
150 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
czy412 2002-12-19
  • 打赏
  • 举报
回复
注意xsl中html的时候,html必须是格式完好的html!!
类似与xml一样!
ssm1226 2002-12-19
  • 打赏
  • 举报
回复
<iframe src="1.html" frameborder=0 width=100% height=30></iframe>
saucer 2002-12-19
  • 打赏
  • 举报
回复
that is why you need to use
disable-output-escaping="yes"
saucer 2002-12-19
  • 打赏
  • 举报
回复
sorry, my mistake, a moment of weakness, :-), "include" will be useless when sent in html

if you are using XSLT, put your html code betwen <![CDATA[....]]>, for example (note, this is a valid XML document):

testheader.html:
<html>
<![CDATA[
<a href="http://www.csdn.net">CSDN</a><BR>
<input type="button" value="click" onclick="showClick()">
<script language="javascript">
function showClick()
{
alert("yes");
}
</script>
]]>
</html>

inside your XML, you do

test.xml:

<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<html>
<include file="testheader.html" />
</html>

inside your XSLT, you do

test.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of disable-output-escaping="yes" select="document(html/include/@file)/html" />
</xsl:template>
</xsl:stylesheet>
zhujjcn 2002-12-19
  • 打赏
  • 举报
回复
to saucer(思归, MS .NET MVP)
这样行吗?我怎么键入xml文件后就是空空如也,不过html/include/@file结点内容是对的,把disable-output-escaping改成no的话就输出<![CDATA[ CSDN function showClick() { alert("yes"); } ]]> ??
lshdic 2002-12-18
  • 打赏
  • 举报
回复
<?xml version='1.0' encoding='gb2312'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">

<xsl:comment>
#include file="hr.htm"
</xsl:comment>

<table>
<xsl:for-each select="document/page">
<tr>
<td><xsl:value-of select="messgdates"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

运行时竟然不通过,浏览器返回的错误码是乱码我也看不清楚,在这个XML文件的相同目录中是有一个 hr.htm 的文件,其内容就5个字是 <hr/> ,不知是我的名域定义错误了还是怎么了哪?
saucer 2002-12-18
  • 打赏
  • 举报
回复
1. use a tool like Tidy to convert the html file XML-compliant
or

2. if you are doing the transformation on the server side, use a line like
<xsl:comment>#include file="yourhtmlfile.html"</xsl:comment>

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧