【发布时间】: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当然不能神奇地做正确的事情,但它有各种属性,如count和from和level,可以做一些“魔法”。 -
嵌套
topics 或许<xsl:number count="topic" level="multiple"/>是有道理的。但是你确实需要展示你想要生成的输出结构和数字结构。 -
谢谢@MartinHonnen,
-
查看下面我当前的输出,它只选择第 2 页
-
content here contenet here
2这里的内容 这里的内容
2