I want use diazo to replace a attribute, but diazo's <replace /> statement with attributes is not work?

309 Views Asked by At

I have some code as below, but attribute 'src' not replace,

<?xml version="1.0" encoding="UTF-8"?>
<rules
    xmlns="http://namespaces.plone.org/diazo"
    xmlns:css="http://namespaces.plone.org/diazo/css"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <rules css:if-content="#visual-portal-wrapper">

        <theme href="index.html" />
        <replace css:content="a#portal-logo img" css:theme="h1.logo a img" attributes="src"/>

    </rules>

</rules>

Why? is a bug? or I make a mistake? Have any suggestions ?

2

There are 2 best solutions below

4
Danimal On

Try using copy instead of replace. As Diazo docs say in replace section...

Note: As with rules working on tags, if the named attribute(s) do not exist on the both the theme and content nodes, nothing will happen. If you want to copy attributes regardless of whether they exist on the theme node(s) or not, you can use instead.

3
Vito On

if you set, in your theme, src="" you can use also

<merge attributes="class" css:theme="h1.logo a img" css:content="a#portal-logo img" />

or

<replace css:content-children="a#portal-logo img" attribute="src">
        <xsl:attribute name="src"><xsl:value-of select="./@src"/></xsl:attribute>
        <xsl:apply-templates />
</replace>