初学xsl,在firefox中有问题请指教

afoskoo 2006-04-11 09:21:01
example_1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="example_1.xsl"?>
<source>
<color>blue</color>
<color>navy</color>
<color>green</color>
<color>lime</color>
<color>red</color>
<color>#036</color>
</source>

example_1.xsl:
<xsl:stylesheet version = '1.0'
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="color">
<TABLE>
<TR>
<TD>
<xsl:attribute name="style">
<xsl:text>color:</xsl:text>
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/>
</TD>
</TR>
</TABLE>
</xsl:template>
</xsl:stylesheet>

在IE6中显示结果正常,输出了不同颜色的字体.
但在firefox中却不行,是firefox本身问题还是代码不兼容?
...全文
211 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
colee 2006-04-11
  • 打赏
  • 举报
回复
需要符合XHMTL规范

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="source">
<html><head>
<title>test</title>
</head>
<body>
<xsl:apply-templates select="color"/>
</body>
</html>
</xsl:template>
<xsl:template match="color">
<TABLE>
<TR>
<TD>
<xsl:attribute name="style">
color:<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/> <br/>
</TD>
</TR>
</TABLE>
</xsl:template>
</xsl:stylesheet>
colee 2006-04-11
  • 打赏
  • 举报
回复

原来是color可能在firefox里作为保留字,不允许作xml节点名
colee 2006-04-11
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="source">
<xsl:apply-templates select="color"/>
</xsl:template>
<xsl:template match="color">
<TABLE>
<TR>
<TD>
<xsl:attribute name="style">
<xsl:text>color:</xsl:text>
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/>
</TD>
</TR>
</TABLE>
</xsl:template>
</xsl:stylesheet>
moodboy1982 2006-04-11
  • 打赏
  • 举报
回复
example_1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="example_1.xsl"?>
<source>
<color>blue</color>
<color>navy</color>
<color>green</color>
<color>lime</color>
<color>red</color>
<color>#036</color>
</source>

里面的颜色不用常量来代替吧。
即:<color>#ff0000</color>

---------------
http://www.esoftnow.com/bbs
技术论坛,欢迎光临!
colee 2006-04-11
  • 打赏
  • 举报
回复
<xsl:text> 在firefox里好似不支持,其实这里不用它都行啊

<xsl:attribute name="style">
<xsl:text>color:</xsl:text>
<xsl:value-of select="."/>
</xsl:attribute>

=>
<xsl:attribute name="style">
color:<xsl:value-of select="."/>
</xsl:attribute>
afoskoo 2006-04-11
  • 打赏
  • 举报
回复
刚才试了一下,在Opera中也不行哦,结果跟firefox一样.
:(

8,906

社区成员

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

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