使用XSLT for XML中的javascript在span标记中附加文本

时间:2014-07-23 12:15:43

标签: javascript xml xslt

<xsl:for-each select="ColumnName">
 <span>
    <script  type="text/javascript">document.write("thisStringIsGood".replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); }));</script>                           
 </span>
</xsl:for-each>

此代码抛出错误:

InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable

在常规html中尝试相同的工作

 <span>
    <script  type="text/javascript">document.write("thisStringIsGood".replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); }));</script>                           
 </span>

1 个答案:

答案 0 :(得分:0)

我认为这个问题已在此处提出并回答: Output Javascript document.write in XSL

简短摘要: