我想使用diazo替换属性,但diazo的<replace>语句与属性不起作用?

时间:2015-05-21 14:49:38

标签: plone diazo

我有一些代码如下,但属性'src'不能替换,

<?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>

为什么呢?是个bug?或者我弄错了?有任何建议吗?

2 个答案:

答案 0 :(得分:0)

尝试使用copy代替替换。正如Diazo文档在替换部分中所说的那样......

  

注意:与处理标记的规则一样,如果已命名   主题和内容节点上都不存在属性,   什么都不会发生。如果要复制属性而不管   无论它们是否存在于主题节点上,您都可以使用   代替。

答案 1 :(得分:0)

如果您在主题中设置src =“”,您也可以使用

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

<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>