Plone diazo xsl:在辅助规则文件中不应用模板

Plone diazo xsl:在辅助规则文件中不应用模板,plone,diazo,Plone,Diazo,我将Diazo与Plone一起使用,并且有一些xsl代码在rules.xml的根目录下工作,但不在包含的.xml文件中。我希望保持rules.xml的简单性,并在每个节的.xml文件中保留特定于节的样式 如何使用section-one.xml中的diazo将类“subNav”添加到所有li中 不工作(但需要): rules.xml <?xml version="1.0" encoding="UTF-8"?> <rules xmlns="http://namespaces

我将Diazo与Plone一起使用,并且有一些xsl代码在rules.xml的根目录下工作,但不在包含的.xml文件中。我希望保持rules.xml的简单性,并在每个节的.xml文件中保留特定于节的样式

如何使用section-one.xml中的diazo将类“subNav”添加到所有li中

不工作(但需要):

rules.xml

<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <rules if-path="section-one/">
        <xi:include href="section-one.xml" />
        <theme href="templates/section-one.html" />
    </rules>

    <rules if-not-path="section-two/">
        <xi:include href="section-two.xml" />
        <theme href="templates/section-two.html" />
    </rules>

</rules>
<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <rules if-path="section-one/">
        <xi:include href="section-one.xml" />
        <theme href="templates/section-one.html" />
    </rules>

    <rules if-not-path="section-two/">
        <xi:include href="section-two.xml" />
        <theme href="templates/section-two.html" />
    </rules>
    <xsl:template match="//body[contains(@class, 'section-one')]//li">
        <xsl:copy>
            <xsl:attribute name="class">subNav</xsl:attribute>
             <xsl:apply-templates />
         </xsl:copy>
     </xsl:template>
</rules>

第一节.xml

<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <replace css:content="#content" css:theme="#content"/>
    <xsl:template match="//li">
        <xsl:copy>
            <xsl:attribute name="class">subNav</xsl:attribute>
             <xsl:apply-templates />
         </xsl:copy>
     </xsl:template>
</rules>
<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <replace css:content="#content" css:theme="#content"/>
</rules>

子导航
工作(但不需要):

rules.xml

<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <rules if-path="section-one/">
        <xi:include href="section-one.xml" />
        <theme href="templates/section-one.html" />
    </rules>

    <rules if-not-path="section-two/">
        <xi:include href="section-two.xml" />
        <theme href="templates/section-two.html" />
    </rules>

</rules>
<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <rules if-path="section-one/">
        <xi:include href="section-one.xml" />
        <theme href="templates/section-one.html" />
    </rules>

    <rules if-not-path="section-two/">
        <xi:include href="section-two.xml" />
        <theme href="templates/section-two.html" />
    </rules>
    <xsl:template match="//body[contains(@class, 'section-one')]//li">
        <xsl:copy>
            <xsl:attribute name="class">subNav</xsl:attribute>
             <xsl:apply-templates />
         </xsl:copy>
     </xsl:template>
</rules>

子导航
第一节.xml

<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <replace css:content="#content" css:theme="#content"/>
    <xsl:template match="//li">
        <xsl:copy>
            <xsl:attribute name="class">subNav</xsl:attribute>
             <xsl:apply-templates />
         </xsl:copy>
     </xsl:template>
</rules>
<?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"
    xmlns:xi="http://www.w3.org/2001/XInclude">

    <replace css:content="#content" css:theme="#content"/>
</rules>

使用适当的XSL属性配置每个规则标记,例如,将
第一节.xml
更改为[1]:

<rules
    xmlns="http://namespaces.plone.org/diazo"
    xmlns:css="http://namespaces.plone.org/diazo/css"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <replace css:content="#content" css:theme="#content"/>
    <xsl:template match="//li">
       <xsl:copy>
          <xsl:attribute name="class">subNav</xsl:attribute>
          <xsl:apply-templates />
       </xsl:copy>
    </xsl:template>
</rules>

子导航

[1] 我不确定这是否有效。如果没有,你可以考虑提交一个bug报告

,这实际上与XCube没有任何关系。相反,这是对在构造内部处理内联XSL的限制

正如Diazo文档所指出的:

内联XSL指令必须直接放置在根标记内,并且无条件应用

[顺便说一下,文档中的“无条件”并不完全正确。使用method=“raw”将避免应用特定规则。]

内联XSL通常附加到转换主题后生成的XSL中。Diazo显然不知道如何在一个。所以,它省略了它。这可能是一件好事,因为其他任何事情都可能没有意义

所谓“内联”XSL,我指的是XSL,它不在附加到主题或内容元素的replace、after、before或其他规则中。具体地说,这是任何使用xsl:template的东西

替换中的XSL不受此限制。因此,您可以在section-one.xml中添加以下内容:

<replace css:content="li">
     <xsl:copy>
        <xsl:attribute name="class">subNav</xsl:attribute>
        <xsl:apply-templates />
     </xsl:copy>
</replace>

子导航

然后得到我认为你想要的东西。

很抱歉!我没有包含完整的名称空间以节省一些空间,并使我的问题看起来不那么令人生畏。我一直在用这些名称空间测试它,但我编辑了我的问题,以确保我不会混淆任何其他人。是的,这正是我想要的!另外,如果您想保留当前类并添加新类,您可以使用:
subNav