【问题标题】:Generate footer page number for each p/@outputclass="kingbreak"为每个 p/@outputclass="kingbreak" 生成页脚页码
【发布时间】:2021-09-01 22:59:40
【问题描述】:

输入 Dita 文件

如果任何主题有 p/@outputclass="kingbreak",我们想创建水平页脚页码,我尝试使用 xsl:number/ 但它正在选择乱序页码,请帮助

<?xml version="1.0" encoding="utf-8"?>
<dit xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot">
    <topic>
        <title/>
        <body>
            <p>content here</p>
            <p>content here <ph/>content here</p>
            <p outputclass="kingbreak"/>
        </body>
    </topic>
    <topic>
        <title>SELF title</title>
        <body>
            <p>body content</p>
        </body>
        <topic>
            <title>content here</title>
            <body>
                <p>
                    <b>content here</b>
                </p>
            </body>
            <topic>
                <title>content here</title>
                <body>
                    <section>
                        <p>contenet here</p>
                        <p outputclass="kingbreak"/>
                    </section>
                </body>
            </topic>
            <topic>
                <title>content here</title>
                <body>
                    <section>
                        <p>content here</p>
                        <p outputclass="kingbreak"/>
                    </section>
                </body>
            </topic>
            <topic>
                <title>title content here</title>
                <body>
                    <p>content here</p>
                    <p outputclass="kingbreak"/>
                </body>
            </topic>
            <topic>
                <title>content here</title>
                <body>
                    <section>
                        <p>content here</p>
                        <p outputclass="kingbreak"/>
                    </section>
                </body>
            </topic>
    </topic>
    </topic>
</dit>

XSLT 我尝试使用下面的 xslt,它正在生成随机页码

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    version="2.0">
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="p[contains(@outputclass, 'kingbreak')]">
            <xsl:number/>
            <hr style="border-top:1.5pt solid #000000;" />
    </xsl:template>
    <xsl:stylesheet/>

请帮忙解决一下,先谢谢了

【问题讨论】:

  • 请向我们展示确切的输出结构以及您要生成它们的输出结构中的确切页码和位置。仅仅投入xsl:number当然不能神奇地做正确的事情,但它有各种属性,如countfromlevel,可以做一些“魔法”。
  • 嵌套topics 或许&lt;xsl:number count="topic" level="multiple"/&gt; 是有道理的。但是你确实需要展示你想要生成的输出结构和数字结构。
  • 谢谢@MartinHonnen,
  • 查看下面我当前的输出,它只选择第 2 页
  • content here

    contenet here

    2

    这里的内容

    这里的内容

    2

标签: xslt-2.0 dita


【解决方案1】:

试试&lt;xsl:number level="any" count="p[contains(@outputclass, 'kingbreak')]"/&gt; 是否给你想要的数字序列。

【讨论】:

  • 非常感谢@Martin,一切正常
猜你喜欢
  • 2014-01-06
  • 1970-01-01
  • 2017-05-26
  • 2013-07-31
  • 1970-01-01
  • 1970-01-01
  • 2020-07-22
  • 2020-06-17
  • 1970-01-01
相关资源
最近更新 更多