2015-12-07 57 views
0

我收到了一個引發我的模糊規則匹配錯誤。這是錯誤:XSL含糊不清的規則混淆

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父級,所以爲什麼我會用not(parent :: levelledPara)的規則匹配來獲得模糊性?我敢肯定,我可能錯過了一些荒謬簡單的東西,希望一些新鮮的觀點能夠抓住它。僅僅是因爲我在使用兩個不同父級標籤(levelledPara和proceduralStep)的match語句中有「or」?

XSL:

<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> 

回答

1

這是因爲levelledPara/table比賽都table[parent::levelledPara]table[not(parent::proceduralStep)]。你大概的意思是寫:而不是

<xsl:template match="table[not(parent::levelledPara or parent::proceduralStep)]"> 

<xsl:template match="table[not(parent::levelledPara)] | table[not(parent::proceduralStep)]"> 

Is it simply because I have an "or" in the match statements using two different parent tags (levelledPara and proceduralStep)?

但你沒有一個or。您有union運營商。而你是工會表,而不是他們的父母。這也可以發揮作用:

<xsl:template match="table[not(parent::levelledPara | parent::proceduralStep)]"> 
+0

把這兩個混在一起,對此感覺有點愚蠢。這解決了表問題。我還收到了我設法解決的表格中的兒童(入門內容)的含糊不清。謝謝您的幫助。 – twfurst