+ -
当前位置:首页 → 问答吧 → xslt 中<xsl:attribute name="@name">有办法实现吗?

xslt 中<xsl:attribute name="@name">有办法实现吗?

时间:2011-07-28

来源:互联网

xml的内容:
<?xml version="1.0" encoding="utf-8"?>
<template name="onclick">
  <action>
  jsFunctionName
  </action>
</template>
xsl的内容:
<xsl:apply-templates select"/">
  <html>
  <body>
  <form>
  <table>
  <xsl:if test="@name">
  <xsl:attribute name="@name"> <xsl:value-of select="./action"/>
  </xsl:attribute>
  </xsl:if>
  </table>
  </form>
  </body>
  <html>
</xsl:apply-templates>

作者: shanghuaipopu   发布时间: 2011-07-28

自己解决,水平太烂,暂时不知道为什么。但是效果出来啦。

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="template">
<html>
<head>
<title>333333333</title>
</head>
<body>
<table>

<xsl:if test="@name">
<xsl:attribute name="{@name}"> <xsl:value-of select="./action">
</xsl:value-of>
</xsl:attribute>
<tbody>
<tr>
<th><xsl:value-of select="./action">
</xsl:value-of></th>
</tr>
</tbody>



</xsl:if>

</table>
</body>

</html>
</xsl:template>
</xsl:stylesheet>

作者: shanghuaipopu   发布时间: 2011-07-28