2017-05-05 3 views
0

을 포장 할 때 다시 시작 : 나는, <proceduralStep>를 계산 <xsl:number>를 사용하여 속성 @changeType='delete'을 가진 부모 나 아이가 어떤 proceduralStep를 제외하고있어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> 

. (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 샘플에 포함 시키시겠습니까? 나는 당신이 보여준 것만을 감싸고 있다고 가정하지만 그것이 존재한다면 더 분명해질 것입니다. –

+0

여기에 문제를 재현 할만한 정보가 충분하지 않으므로'level = "multiple"을''level = 'any' '로 변경하는 것이 좋습니다. –

+0

감사합니다. 중첩 된'proceduralSteps'이 있기 때문에'level = 'multiple'이 필요합니다. – Caroline

답변

0

xsl:number은 형제 (또는 level="any"의 경우 precedingancestor-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>