首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >diazo :在辅助规则文件中不应用的模板

diazo :在辅助规则文件中不应用的模板
EN

Stack Overflow用户
提问于 2013-06-19 22:00:18
回答 2查看 851关注 0票数 4

我在Plone中使用了Diazo,并且有一些在rules.xml根目录中工作的xsl代码,但没有在包含的.xml文件中工作。我想让我的rules.xml保持简单,并在每个部分的.xml文件中保持该节的特定样式。

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

不工作(但需要):

rules.xml

代码语言:javascript
复制
<?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>

section-one.xml

代码语言:javascript
复制
<?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>

工作(但不需要):

rules.xml

代码语言:javascript
复制
<?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>

section-one.xml

代码语言:javascript
复制
<?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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-06-22 00:29:34

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

正如重氮文件所指出的:

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

顺便说一句,文档中的“未编码”并不完全正确。使用method="raw“将避免对特定规则的应用。

内联XSL通常在转换主题之后追加到生成的XSL。重氮显然不知道如何处理赤裸裸的XSL在一个。所以,它忽略了它。这可能是一件好事,因为其他任何事情都可能没有意义。

所谓“内联”XSL,我指的是没有在替换、后面、之前或附加到主题或内容元素的其他规则中的XSL。具体来说,这是使用xsl:template的任何东西。

替换中的XSL不受此限制的约束。因此,您可以将以下内容放在您的部分-one.xml中:

代码语言:javascript
复制
<replace css:content="li">
     <xsl:copy>
        <xsl:attribute name="class">subNav</xsl:attribute>
        <xsl:apply-templates />
     </xsl:copy>
</replace>

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

票数 8
EN

Stack Overflow用户

发布于 2013-06-19 22:34:55

用适当的XSL属性配置每个规则标记,例如,将section-one.xml更改为1

代码语言:javascript
复制
<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>

我不确定这能不能用。如果没有,您可以考虑提交错误报告。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17202134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档