如何xslt解析XML的时候,能够调用JS的函数?!

itfly 2006-01-09 11:34:52
<xsl:when test="@href">
<a>
<xsl:choose>
<xsl:when test="@target">
<xsl:attribute name="target"><xsl:value-of select="@target" /></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="target">self</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="tabindex">-1</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
<xsl:value-of select="@text" />
</a>
</xsl:when>
这一段是检测到HREF产生一个URL的连接,如何检测到@js,产生一个onclick的事件呢?!

...全文
194 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssm1226 2006-01-09
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="33.xsl"?>
<root>
<a href='http://www.sohu.com' target='_blank' js='alert(11);' text='sohu'></a>
<a href='http://www.sina.com.cn' target='_blank' js='alert(22);' text='sina'></a>
</root>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<xsl:for-each select="//a">
<xsl:if test="@href">
<a>
<xsl:choose>
<xsl:when test="@target">
<xsl:attribute name="target"><xsl:value-of select="@target" /></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="target">self</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@js"><xsl:attribute name="onclick"><xsl:value-of select="@js"/></xsl:attribute></xsl:if>
<xsl:attribute name="tabindex">-1</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
<xsl:value-of select="@text" />
</a>
</xsl:if>

<hr/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

8,906

社区成员

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

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