我试图通过使用我从内容中选择的值计算 URL 来更改主题href
中某些元素的 s 。<a>
但是,我根本不知道如何更改 href 属性。似乎规则attributes
中没有理解该属性<replace>
。
最终,我希望能够做类似的事情:
<replace css:theme="a.languageswitcher" attributes="href">
<!-- use some XSL logic here to stitch together the new href -->
</replace>
所以以下规则有效,但对我没用:
<copy attributes="href" css:theme="a.languageswitcher" css:content="#portal-logo" />
<merge attributes="href" css:theme="a.languageswitcher" css:content="#portal-logo" />
但是这个已经不起作用了attributes="href"
,所以这个规则被忽略了。
<replace attributes="href" css:theme="a.languageswitcher" css:content="#portal-logo" />
另一方面,如果我尝试<a>
从头开始重建元素,那么我会遇到@ross-patterson 在他的问题中描述的错误:Diazo - Conditionally add a class to a theme element:
<replace theme="//a[@class='languageswitcher']">
<a class="languageswitcher">
<xsl:attribute name='href'>
foo
</xsl:attribute>
</a>
</replace>
产生错误:
XSLTApplyError: xsl:attribute: Cannot add attributes to an element if children have been already added to the element.
如何才能做到这一点?