1

我正在使用 docbook,并且正在使用将零宽度字符插入到我的表格条目中的模板。这很好,但如果表条目包含一个元素,我需要不应用模板。<para>那么,有没有办法可以将模板应用于所有<entry>不包含 a 的内容<para>

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:d="http://docbook.org/ns/docbook">
<xsl:import href="urn:docbkx:stylesheet"/>

...

<xsl:template match="text()[parent::d:entry]">
    <xsl:call-template name="intersperse-with-zero-spaces">
        <xsl:with-param name="str" select="."/>
    </xsl:call-template>
</xsl:template>

...

4

2 回答 2

2

<xsl:template match="d:entry[not(d:para)]">匹配任何entry没有para子元素的元素。<xsl:template match="d:entry[not(descendant::d:para)]">匹配任何entry没有任何para后代的元素。

或者对于您发布的模板,您可以使用<xsl:template match="text()[parent::d:entry[not(d:para)]]">.

于 2011-01-12T17:44:42.827 回答
1
<xsl:template match="text()[parent::d:entry[not(.//d:para)]]">
    <xsl:call-template name="intersperse-with-zero-spaces">
        <xsl:with-param name="str" select="."/>
    </xsl:call-template>
</xsl:template>
于 2011-01-12T17:45:05.090 回答