首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XSL模糊规则混淆

XSL模糊规则混淆
EN

Stack Overflow用户
提问于 2015-12-07 12:59:09
回答 1查看 89关注 0票数 0

我收到一个模糊的规则匹配错误,正在抛出我。这是一个错误:

代码语言:javascript
复制
Recoverable error 
  XTRE0540: Ambiguous rule match for
  /dmodule/content[1]/description[1]/levelledPara[2]/levelledPara[4]/table[1]
Matches both "table[parent::levelledPara] | table[parent::proceduralStep]" on line 3047 of
  file:/c:/users/c79460/AppData/Local/PWC%20PDF%20Generator/test3.xsl
and "table[not(parent::levelledPara)] | table[not(parent::proceduralStep)]" on line 2962
  of file:/c:/users/c79460/AppData/Local/PWC%20PDF%20Generator/test3.xsl

我看不出根据所引用的两条规则和它所匹配的道路,哪里会有任何含糊不清的地方。在我看来,这个表有一个levelledPara父表,所以为什么我会得到不匹配规则的歧义(父表::平面parent )?我相信我可能错过了一些可笑的简单的东西,希望一些新的视角会抓住它。这仅仅是因为我在match语句中使用了两个不同的父标记(levelledPara和proceduralStep)。

XSL:

代码语言:javascript
复制
<xsl:template match="table[not(parent::levelledPara)] | table[not(parent::proceduralStep)]">
    <xsl:variable name="TId" select="@id"/>
    <xsl:variable name="tCount">
        <xsl:number level="any" count="table" format="1"/>
    </xsl:variable>
    <fo:table table-layout="fixed" width="100%" id="{$TId}" ><!--margin-left="-10mm" -->
        <fo:table-column column-width="proportional-column-width(1)"/>
        <fo:table-header>
            <fo:table-row>
                <fo:table-cell>
                    <xsl:if test="title/text()">
                        <!--border="1 solid black" --><fo:block keep-with-next="always" text-align="center" padding-top="8pt" padding-bottom="2pt" space-after="2pt" margin-left="-10mm">
                            <fo:inline font-style="italic">Table <xsl:value-of select="$tCount"/>
                                <xsl:value-of select="concat(' - ', ./title)"/></fo:inline>
                            <fo:retrieve-table-marker retrieve-class-name="tab-cont" 
                                retrieve-position-within-table="first-starting" 
                                retrieve-boundary-within-table="table"/>
                        </fo:block>
                    </xsl:if>
                    <xsl:if test="not(title/text())">
                        <fo:block keep-with-next="always" text-align="center" space-after="2pt">
                            <fo:inline font-style="italic">Table <xsl:value-of select="$tCount"/>
                                </fo:inline>
                            <fo:retrieve-table-marker retrieve-class-name="tab-cont" 
                                retrieve-position-within-table="first-starting" 
                                retrieve-boundary-within-table="table"/>
                        </fo:block>
                    </xsl:if>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-header>
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell>
                    <fo:marker marker-class-name="tab-cont"/>
                    <fo:block/>
                </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
                <fo:table-cell>
                    <fo:marker marker-class-name="tab-cont">&#x00A0;- (Continued)</fo:marker>
                    <fo:block keep-with-previous="always">
                        <fo:marker marker-class-name="tab-cont">&#x00A0;- (Continued)</fo:marker>
                        <fo:table table-layout="fixed" width="100%">
                            <xsl:for-each select="colspec">
                                <fo:table-column column-width="proportional-column-width(@colwidth)"/>
                            </xsl:for-each>
                            <fo:table-header>
                                <xsl:for-each select="./tgroup/thead/row">
                                    <fo:table-row>
                                        <xsl:apply-templates/>
                                    </fo:table-row>
                                </xsl:for-each>
                            </fo:table-header>
                            <fo:table-footer>
                                <fo:table-row>
                                    <xsl:for-each select="./tgroup/thead/row[1]/entry"><!--[position() &gt; 1]-->
                                        <fo:table-cell border-top-style="solid" border-top-color="black" border-collapse="collapse">
                                            <fo:block/>
                                        </fo:table-cell>
                                    </xsl:for-each>
                                </fo:table-row>
                            </fo:table-footer>
                            <fo:table-body>
                                <xsl:for-each select="./tgroup/tbody/row">
                                    <fo:table-row>
                                        <xsl:apply-templates/>
                                    </fo:table-row>
                                </xsl:for-each>
                                <xsl:if test="./tgroup/tfoot">
                                    <xsl:for-each select="./tgroup/tfoot/row">
                                        <fo:table-row>
                                            <xsl:apply-templates/>
                                        </fo:table-row>
                                    </xsl:for-each>
                                </xsl:if>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
</xsl:template>

<xsl:template match="table[parent::levelledPara] | table[parent::proceduralStep]">
    <xsl:variable name="TId" select="@id"/>
    <xsl:variable name="tCount">
        <xsl:number level="any" count="table" format="1"/>
    </xsl:variable>
    <fo:table table-layout="fixed" width="93%" id="{$TId}" margin-left="-10mm"><!--margin-left="-10mm" -->
        <fo:table-column column-width="proportional-column-width(1)"/>
        <fo:table-header>
            <fo:table-row>
                <fo:table-cell>
                    <xsl:if test="title/text()">
                        <!--border="1 solid black" --><fo:block keep-with-next="always" text-align="center" padding-top="8pt" padding-bottom="2pt" space-after="2pt" margin-left="-10mm">
                            <fo:inline font-style="italic">Table <xsl:value-of select="$tCount"/>
                                <xsl:value-of select="concat(' - ', ./title)"/></fo:inline>
                            <fo:retrieve-table-marker retrieve-class-name="tab-cont" 
                                retrieve-position-within-table="first-starting" 
                                retrieve-boundary-within-table="table"/>
                        </fo:block>
                    </xsl:if>
                    <xsl:if test="not(title/text())">
                        <fo:block keep-with-next="always" text-align="center" space-after="2pt">
                            <fo:inline font-style="italic">Table <xsl:value-of select="$tCount"/>
                            </fo:inline>
                            <fo:retrieve-table-marker retrieve-class-name="tab-cont" 
                                retrieve-position-within-table="first-starting" 
                                retrieve-boundary-within-table="table"/>
                        </fo:block>
                    </xsl:if>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-header>
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell>
                    <fo:marker marker-class-name="tab-cont"/>
                    <fo:block/>
                </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
                <fo:table-cell>
                    <fo:marker marker-class-name="tab-cont">&#x00A0;- (Continued)</fo:marker>
                    <fo:block keep-with-previous="always">
                        <fo:marker marker-class-name="tab-cont">&#x00A0;- (Continued)</fo:marker>
                        <fo:table table-layout="fixed" width="100%">
                            <xsl:for-each select="colspec">
                                <fo:table-column column-width="proportional-column-width(@colwidth)"/>
                            </xsl:for-each>
                            <fo:table-header>
                                <xsl:for-each select="./tgroup/thead/row">
                                    <fo:table-row>
                                        <xsl:apply-templates/>
                                    </fo:table-row>
                                </xsl:for-each>
                            </fo:table-header>
                            <fo:table-footer>
                                <fo:table-row>
                                    <xsl:for-each select="./tgroup/thead/row[1]/entry"><!--[position() &gt; 1]-->
                                        <fo:table-cell border-top-style="solid" border-top-color="black" border-collapse="collapse">
                                            <fo:block/>
                                        </fo:table-cell>
                                    </xsl:for-each>
                                </fo:table-row>
                            </fo:table-footer>
                            <fo:table-body>
                                <xsl:for-each select="./tgroup/tbody/row">
                                    <fo:table-row>
                                        <xsl:apply-templates/>
                                    </fo:table-row>
                                </xsl:for-each>
                                <xsl:if test="./tgroup/tfoot">
                                    <xsl:for-each select="./tgroup/tfoot/row">
                                        <fo:table-row>
                                            <xsl:apply-templates/>
                                        </fo:table-row>
                                    </xsl:for-each>
                                </xsl:if>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
</xsl:template>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-07 13:18:02

这是因为levelledPara/tabletable[parent::levelledPara]table[not(parent::proceduralStep)]都匹配。你可能打算写:

代码语言:javascript
复制
<xsl:template match="table[not(parent::levelledPara or parent::proceduralStep)]">

而不是:

代码语言:javascript
复制
<xsl:template match="table[not(parent::levelledPara)] | table[not(parent::proceduralStep)]">

这仅仅是因为我在match语句中使用了两个不同的父标记(levelledPara和proceduralStep)。

但你没有or。您有union接线员。你是在联合桌子而不是他们的父母。这也会奏效的:

代码语言:javascript
复制
<xsl:template match="table[not(parent::levelledPara | parent::proceduralStep)]">
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34134165

复制
相关文章

相似问题

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