I am trying to change the href
s of certain <a>
elements in the theme by computing the URLs using values I select from the content. However, I can't figure out how to change the href attribute at all. It seems like the attributes
attribute is not understood in the <replace>
rule.
Ultimately, I would like to be able to do something like:
<replace css:theme="a.languageswitcher" attributes="href">
<!-- use some XSL logic here to stitch together the new href -->
</replace>
So the following rules work, but are useless to me:
<copy attributes="href" css:theme="a.languageswitcher" css:content="#portal-logo" />
<merge attributes="href" css:theme="a.languageswitcher" css:content="#portal-logo" />
But this one already does not work, the attributes="href"
makes it so this rule is ignored.
<replace attributes="href" css:theme="a.languageswitcher" css:content="#portal-logo" />
On the other hand, if I try to rebuild the <a>
element from scratch, then I run into the error described by @ross-patterson in his question: 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>
produces the error:
XSLTApplyError: xsl:attribute: Cannot add attributes to an element if children have been already added to the element.
How can this be done?