【发布时间】:2018-10-19 22:25:14
【问题描述】:
我有一个 XSLT 模板,它计算所有级别的主题,用于在我拥有的 DITA 项目中用编号标记这些主题。
<xsl:template match="*[contains(@class, ' bookmap/chapter ')] | *[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class,' bookmap/frontmatter ')])]" mode="topicTitleNumber">
<xsl:number format="1 " count="*[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class,' bookmap/frontmatter ')])] | *[contains(@class, ' bookmap/chapter ')]" level="multiple"/>
</xsl:template>
我正在尝试为计数内容添加额外的排除项,因为当 topicref 类的 title 元素具有 outputclass 的 noNum 时。
<xsl:template match="*[contains(@class, ' bookmap/chapter ')] | *[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class,' bookmap/frontmatter ')])]" mode="topicTitleNumber">
<xsl:number format="1 " count="*[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class,' bookmap/frontmatter ')] | *[contains(title/@outputclass, 'noNum')])] | *[contains(@class, ' bookmap/chapter ')]" level="multiple"/>
</xsl:template>
如上所示,我在第一个not 语句之后添加了| *[contains(title/@outputclass, 'noNum')],认为这将作为一个附加条件,其中count 调用将在调用模板时跳过(即...不是具有 [criteria] 的祖先或自我或标题 outputclass 属性为“noNum”的主题...)。但是,我添加的条件似乎被视为模板确实匹配和计数的东西。
假设我在最后一点上是正确的,我认为我需要将该条件放在它自己的“非”语句中,但我不确定如何使用 XPath 中已经存在的条件来做到这一点。
【问题讨论】:
标签: xml xslt xpath xsl-fo dita