2017-05-05 19 views
0

ラップされたときに番号が再起動します。XSL:カウント要素は、XSLT 1.0 XSL-FOを考える

<dmodule> 
<content> 
<procedure> 
<mainProcedure> 
<proceduralStep> 
<proceduralStep id="ps-111-222-test"> 
<title>Air Valve Assemblies</title> 
<proceduralStep> 
<title>General</title><proceduralStep><para>Equivalent substitutes can be used for items listed in the Table</para> 
</proceduralStep></proceduralStep></proceduralStep> 
    <proceduralStep><para>Continue with this</para><para>Hold air valve plate</para></proceduralStep> 
    <proceduralStep><para>Turn the screw....</para><para>Install bushing</para></proceduralStep> 
    <proceduralStep><para>Hold assembly tool....</para><para>Install spring seat</para></proceduralStep> 
    <proceduralStep><para>Install plug</para></proceduralStep> 
    </proceduralStep> 
    <proceduralStep> 
<proceduralStep id="ps-111-223-test"> 
<title>Water Valve Assemblies</title> 
<proceduralStep> 
<title>General</title><proceduralStep><para>Equivalent substitutes can be used for items listed in the Table</para> 
</proceduralStep></proceduralStep></proceduralStep> 
    <proceduralStep><para>Continue with this</para><para>Rotate water valve plate</para></proceduralStep> 
    <proceduralStep><para>Install housing....</para><para>Install bushing</para></proceduralStep> 
    <proceduralStep><para>Hold water valve plate....</para><para>Install spring seat</para></proceduralStep> 
    <proceduralStep><para>Install actuator assembly</para></proceduralStep> 
    </proceduralStep> 
    </mainProcedure> 
    </procedure> 
</content> 
</dmodule> 

私は、属性@changeType='delete'を持つ親や子を持つ任意のproceduralStep除く、<proceduralStep>をカウントする<xsl:number>を使用しています。 (proceduralStepsはネストすることができる。)

<xsl:template match="proceduralStep"> 
     <fo:list-block> 
      <fo:list-item> 
       <fo:list-item-label> 
        <fo:block> 
         <xsl:number count="proceduralStep[not(*/@changeType = 'delete' or parent::*/@changeType = 'delete')]" from="content" level="multiple" format="1.1.1.1.1"/> 
        </fo:block> 
       </fo:list-item-label> 
      </fo:list-item> 
     </fo:list-block> 
</xsl:template> 

を予想通り<revst><proceduralStep>

<dmodule> 
    <content> 
    <procedure> 
    <mainProcedure> 
    <proceduralStep> 
    <proceduralStep id="ps-111-222-test"> 
    <title>Air Valve Assemblies</title> 
    <proceduralStep> 
    <title>General</title><proceduralStep><para>Equivalent substitutes can be used for items listed in the Table</para> 
    </proceduralStep></proceduralStep></proceduralStep> 
     <proceduralStep><para>Continue with this</para><para>Hold air valve plate</para></proceduralStep> 
     <proceduralStep><para>Turn the screw....</para><para>Install bushing</para></proceduralStep> 
     <proceduralStep><para>Hold assembly tool....</para><para>Install spring seat</para></proceduralStep> 
     <proceduralStep><para>Install plug</para></proceduralStep> 
     </proceduralStep> 
     <proceduralStep> 
    <proceduralStep id="ps-111-223-test"> 
    <title>Water Valve Assemblies</title> 
    <proceduralStep> 
    <title>General</title><proceduralStep><para>Equivalent substitutes can be used for items listed in the Table</para> 
    </proceduralStep></proceduralStep></proceduralStep> 
     <proceduralStep><para>Continue with this</para><para>Rotate water valve plate</para></proceduralStep> 
     <revst changeMark="1"> 
     <proceduralStep><para>Install housing....</para><para>Install bushing</para></proceduralStep> 
     <proceduralStep><para>Hold water valve plate....</para><para>Install spring seat</para></proceduralStep> 
     </revst> 
     <proceduralStep><para>Install actuator assembly</para></proceduralStep> 
     </proceduralStep> 
     </mainProcedure> 
     </procedure> 
    </content> 
    </dmodule> 

のラッパーそしてナンバリングが再起動されますされない限り、これは、動作:

1.2.13 Continue with this. Rotate water valve plate 
    1.2.1 Install housing...Install bushing 
    1.2.2 Hold water valve plate....Install spring seat 
    1.2.14 Install actuator assembly 

代わりに:

1.2.13 Continue with this. Rotate water valve plate 
    1.2.14 Install housing...Install bushing 
    1.2.15 Hold water valve plate....Install spring seat 
    1.2.16 Install actuator assembly 

10は、だから私は

<xsl:number count="revst[not(@changeType = 'delete')] | proceduralStep[not(*/@changeType = 'delete' or parent::*/@changeType = 'delete')]" from="content" level="multiple" format="1.1.1.1.1"/> 

を試してみましたそして今、私は私が xsl:numberがカウント式ではない任意の要素を無視することになっていると思った
1.2.13 Continue with this. Rotate water valve plate 
    1.2.14.1 Install housing...Install bushing 
    1.2.14.2 Hold water valve plate....Install spring seat 
    1.2.15 Install actuator assembly 

を取得しています。

+0

あなたは '置くことができますあなたのXMLサンプルに「content」はありますか?私はあなたが見せているものだけを包むと仮定しますが、存在していればもっと明確になります。 –

+0

問題を再現するのに十分な情報がここにないので、 'level =" multiple "を' 'level = 'any"に変更することを推測してお勧めします。 –

+0

ありがとう、私は例を完成させました。入れ子になった 'proceduralSteps'があるので' level = 'multiple'が必要です – Caroline

答えて

0

xsl:numberは、兄弟(またはlevel="any"の場合、precedingおよびancestor-or-self軸に沿ってカウントされます)。 https://www.w3.org/TR/xslt#numberを参照してください。したがって、それはrevst内の兄弟を数えるときに行うことを意味しています。リストの番号付けを行うための処理の前に(fo:change-bar-beginfo:change-bar-endの方法で)別々の「マイルストーン」が空要素に<revst></revst>になっていると

マイ好ましい溶液は、前処理段階のためになります。それが存在しない場合には

、あなたは(あなたの代わりにXSLT 1.0のXSLT 2.0を使用していた場合にはそれほど冗長になります)あなた自身のためのマルチレベルのカウントを実行する必要があります。

<xsl:template name="preceding-step-count"> 
    <xsl:value-of 
    select="count(preceding-sibling::proceduralStep[not(*/@changeType = 'delete' or parent::*/@changeType = 'delete')]) + 
    count(preceding-sibling::revst/proceduralStep[not(*/@changeType = 'delete' or parent::*/@changeType = 'delete')])"/> 
</xsl:template> 

<xsl:template match="proceduralStep"> 
    <xsl:param name="current-count" select="0"/> 
    <xsl:param name="parent-label" /> 

    <xsl:variable name="preceding-step-count"> 
    <xsl:call-template name="preceding-step-count" /> 
    </xsl:variable> 

    <xsl:variable name="label"> 
    <xsl:value-of 
     select="$current-count + $preceding-step-count + 1"/> 
    </xsl:variable> 

    <xsl:variable name="use-label"> 
    <xsl:choose> 
     <xsl:when test="$parent-label"> 
     <xsl:value-of select="concat($parent-label, '.', $label)"/> 
     </xsl:when> 
     <xsl:otherwise> 
     <xsl:value-of select="$label"/> 
     </xsl:otherwise> 
    </xsl:choose> 
    </xsl:variable> 
    <fo:list-block provisional-distance-between-starts="36pt"> 
    <fo:list-item> 
     <fo:list-item-label end-indent="label-end()"> 
     <fo:block> 
      <xsl:value-of select="$use-label"/> 
     </fo:block> 
     </fo:list-item-label> 
     <fo:list-item-body start-indent="body-start()"> 
     <xsl:apply-templates> 
      <xsl:with-param name="parent-label" select="$use-label" /> 
     </xsl:apply-templates> 
     </fo:list-item-body> 
    </fo:list-item> 
    </fo:list-block> 
</xsl:template> 

<xsl:template match="revst"> 
    <xsl:param name="parent-label" /> 

    <!-- If using XSLT 2.0, could use tunnel parameters 
    and avoid passing $parent-label. --> 
    <xsl:apply-templates> 
    <xsl:with-param name="current-count"> 
     <xsl:call-template name="preceding-step-count" /> 
    </xsl:with-param> 
    <xsl:with-param name="parent-label" select="$parent-label" /> 
    </xsl:apply-templates> 
</xsl:template> 

<xsl:template match="para | title"> 
    <fo:block> 
    <xsl:apply-templates /> 
    </fo:block> 
</xsl:template>