Given:
<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>
I'm using <xsl:number>
to count <proceduralStep>
, excluding any proceduralStep that has a parent or child with attribute @changeType='delete'
. (proceduralSteps
can be nested.)
<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>
This works as expected, unless <revst>
is a wrapper for <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>
Then the numbering gets restarted:
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
instead of:
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
So I tried
<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"/>
And now I'm getting
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
I thought xsl:number
is supposed to ignore any elements not in the count expression.
xsl:number
counts siblings (or, forlevel="any"
, counts along thepreceding
andancestor-or-self
axes). See https://www.w3.org/TR/xslt#number. So it's doing what it's meant to do when it's counting siblings within therevst
.My preferred solution would be for an earlier processing stage to have turned the
<revst>
and</revst>
into separate 'milestone' empty elements (in the manner offo:change-bar-begin
andfo:change-bar-end
) before processing to do the list numbering.In the absence of that, you have to do the multi-level counting for yourself (which would be less verbose if you were using XSLT 2.0 instead of XSLT 1.0):