xsl:attribute:如果已将子元素添加到元素中,则无法向元素添加属性

时间:2014-02-18 01:08:12

标签: ruby-on-rails ruby xml xslt

我有这个xml:

https://gist.github.com/kev-omniata-com/9062497

我正在尝试将此xsl应用于:

https://gist.github.com/kev-omniata-com/9062508

使用这个宝石:

https://github.com/glejeune/ruby-xslt

我收到以下错误:

runtime error: file style.xsl line 209 element attribute
xsl:attribute: Cannot add attributes to an element 
if children have been already added to the element.

我不确定这意味着什么。当我使用firefox查看xml并链接到xsl表时,它会正确呈现。

1 个答案:

答案 0 :(得分:1)

在黑暗中拍摄,但可能是行197

196: <xsl:if test="@*">
197:  <xsl:text>|</xsl:text>
198:  <xsl:for-each select="@*">

稍后在设置属性之前,您将添加元素的文本。也许尝试将其移到<xsl:if>块的底部?