/ .. / / -> download
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format">
    
	<!-- 9/15/11 - kr - added pm classification to header and footer of chapter pages -->
	<!-- 8/30/11 - kr - added code to support the dm sequence number in the page number -->
    <!-- 8/30/11 - kr - added chapter title pages -->
    
    <!--MIL-STD-3031A, para 5.69.1.2 Use of publication modules.
    Publication modules shall be used to sequence data modules for the preparation of all pageoriented
    and interactive electronic publications. (JS)-->

    <!--5.69.1.3 Language.
    Within the element <language>, the country code shall specify United States 
    and the language code shall specify English (<language countryIsoCode="US" languageIsoCode="en"/>)
    or Simplified Technical English (<language countryIsoCode="US" languageIsoCode="sx"/>).-->
    <!-- language element seen in: dmRefIdent, pmIdent, pmRefIdent, sourcePmIdent, !ENTITY % dc..language   -->

    <xsl:variable name="pmcode">
        <xsl:apply-templates select="//pm/identAndStatusSection/pmAddress/pmIdent/pmCode"/>
    </xsl:variable>

    <xsl:template match="pm">
        <xsl:call-template name="pmFrontCover"/>
        <xsl:apply-templates select="content"/>
    </xsl:template>

    <xsl:template match="pm" mode="pm">
        <xsl:apply-templates select="content"/>
    </xsl:template>

    <xsl:template match="pm/content">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template name="pmFrontCover">
        <fo:page-sequence xmlns:fo="http://www.w3.org/1999/XSL/Format"
            force-page-count="end-on-even" initial-page-number="1" language="en"
            master-reference="pmcoverpg" text-align="center">
            <fo:static-content flow-name="pmcoverpg-first-after">
                <xsl:call-template name="FRONT_COVER-FOOTER"/>
            </fo:static-content>
            <fo:static-content flow-name="xsl-region-after">
                <fo:block/>
            </fo:static-content>
            <fo:flow flow-name="region-body">
                <fo:block font-size="20pt" font-weight="bold" space-before.conditionality="discard"
                    space-before.maximum="8pt" space-before.minimum="6pt" space-before.optimum="7pt"
                    span="all" text-align="center">
                    <xsl:call-template name="security"/>
                </fo:block>
                <fo:block font-size="20pt" font-weight="bold" space-before.conditionality="discard"
                    space-before.maximum="8pt" space-before.minimum="6pt" space-before.optimum="7pt"
                    span="all" text-align="center">
                    <xsl:apply-templates select="descendant::pmIdent/pmCode"/>
                </fo:block>
                <fo:block span="all" text-align="start">
                    <fo:leader leader-length="100%" leader-pattern="rule" rule-style="solid"
                        rule-thickness="2pt" space-after="10pt"/>
                </fo:block>
                <fo:block space-after="12pt" space-after.conditionality="discard"
                    space-before.conditionality="discard" space-before.maximum="8pt"
                    space-before.minimum="6pt" space-before.optimum="7pt" span="all">
                    <xsl:apply-templates select="descendant::pmAddressItems/pmTitle"/>
                </fo:block>
                <fo:block space-after="12pt" space-after.conditionality="discard" font-weight="bold"
                    space-before.conditionality="discard" space-before.maximum="8pt"
                    space-before.minimum="6pt" space-before.optimum="7pt" span="all">
                    <xsl:text>FOR</xsl:text>
                </fo:block>
                <fo:block space-after="12pt" space-after.conditionality="discard" font-weight="bold"
                    space-before.conditionality="discard" space-before.maximum="8pt"
                    space-before.minimum="6pt" space-before.optimum="7pt" span="all">
                    <xsl:for-each select="descendant::pmStatus/applic">
                        <xsl:value-of select="displayText/simplePara"/>
                    </xsl:for-each>
                </fo:block>
                <fo:block space-after="12pt" space-after.conditionality="discard"
                    space-before.conditionality="discard" space-before.maximum="8pt"
                    space-before.minimum="6pt" space-before.optimum="7pt" span="all">
                    <xsl:apply-templates select="descendant::pmAddressItems/shortPmTitle"/>
                </fo:block>
            </fo:flow>
        </fo:page-sequence>
    </xsl:template>

    <xsl:template name="FRONT_COVER-FOOTER">
        <fo:block font-size="7pt" text-align="left">
            <xsl:apply-templates select="descendant::supersedure"/>
        </fo:block>
        <fo:block font-size="7pt" text-align="left">
            <xsl:value-of select="descendant::dataDistribution"/>
        </fo:block>
        <fo:block font-size="7pt" text-align="left">
            <xsl:value-of select="descendant::exportControl/exportRegistrationStmt/simplePara"/>
        </fo:block>
        <fo:block font-size="7pt" text-align="left">
            <xsl:value-of select="descendant::dataDestruction"/>
        </fo:block>
        <fo:block font-size="7pt" text-align="left">
            <xsl:value-of select="descendant::remarks/simplePara"/>
        </fo:block>
        <fo:block span="all" text-align="start">
            <fo:leader leader-length="100%" leader-pattern="rule" rule-style="solid"
                rule-thickness="2pt" space-after="10pt"/>
        </fo:block>
        <fo:block font-size="16pt" font-weight="bold" space-after="12pt" space-before.maximum="8pt"
            space-before.minimum="6pt" space-before.optimum="7pt" span="all" text-align="center"
            text-transform="uppercase">
            <xsl:value-of select="descendant::responsiblePartnerCompany/enterpriseName"/>
        </fo:block>
        <fo:block font-size="16pt" font-weight="bold" space-after="12pt" space-before.maximum="8pt"
            space-before.minimum="6pt" space-before.optimum="7pt" span="all" text-align="center"
            text-transform="uppercase">
            <xsl:value-of select="descendant::pmAddressItems/issueDate/@day"/>
            <xsl:text> </xsl:text>
            <xsl:choose>
                <xsl:when test="//pmAddressItems/issueDate/@month='01'">
                    <xsl:text>JANUARY</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='02'">
                    <xsl:text>FEBRUARY</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='03'">
                    <xsl:text>MARCH</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='04'">
                    <xsl:text>APRIL</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='05'">
                    <xsl:text>MAY</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='06'">
                    <xsl:text>JUNE</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='07'">
                    <xsl:text>JULY</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='08'">
                    <xsl:text>AUGUST</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='09'">
                    <xsl:text>SEPTEMBER</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='10'">
                    <xsl:text>OCTOBER</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='11'">
                    <xsl:text>NOVEMBER</xsl:text>
                </xsl:when>
                <xsl:when test="//pmAddressItems/issueDate/@month='12'">
                    <xsl:text>DECEMBER</xsl:text>
                </xsl:when>
            </xsl:choose>
            <xsl:text> </xsl:text>
            <xsl:value-of select="descendant::pmAddressItems/issueDate/@year"/>
        </fo:block>
        <fo:block font-size="20pt" font-weight="bold" space-before.conditionality="discard"
            space-before.maximum="8pt" space-before.minimum="6pt" space-before.optimum="7pt"
            span="all" text-align="center">
            <xsl:call-template name="security"/>
        </fo:block>
    </xsl:template>

    <xsl:template match="pmEntry">
        <!--
        <xsl:if test="not(parent::pmEntry)">
        <xsl:if test="@pmEntryType">
            <fo:block font-size="14pt" font-weight="bold" text-align="center" keep-with-next="auto"
                break-before="page" span="all" margin-top="13pt" margin-bottom="14pt">
                <xsl:apply-templates select="@pmEntryType"/>
            </fo:block>
        </xsl:if>
        </xsl:if>
        -->
        <xsl:if test="@pmEntryType='pmt52'">
        <!--8/30/11 - kr - add page sequence for pmEntry title pages -->
    		<fo:page-sequence master-reference="body-pages" initial-page-number="1"
    			force-page-count="end-on-even" format="1">
    			<fo:static-content flow-name="region-before-odd">
    				
    				<fo:table table-layout="fixed" inline-progression-dimension="100%">
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-body>
    						<fo:table-row>
    							<fo:table-cell number-columns-spanned="2" height="5mm" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>
    
    							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
    								<fo:block text-align="center"
    									font-size="11pt" font-weight="bold" space-after.conditionality="retain">
    									<xsl:call-template name="security"/>
    								</fo:block>
    							</fo:table-cell>
    							<!--S1000D, Section 6.2.1, para 2.4.1.1 Publication module code
    							The publication module code for the complete publication must be located in the header. The
    							publication module code is located in the top outside corner and presented in 11 pt bold, aligned
    							to the outer type limit. -->
    							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
    								<fo:block text-align="end" font-size="11pt" font-weight="bold">
    									<xsl:value-of select="$pmcode"/>
    								</fo:block>
    							</fo:table-cell>
    						</fo:table-row>
    						<fo:table-row padding-after="2pt">
    							<fo:table-cell height="5mm" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>
    							<fo:table-cell padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    						</fo:table-row>
    						<fo:table-row>
    							<xsl:attribute name="border-bottom-style">solid</xsl:attribute>
    							<xsl:attribute name="border-bottom-color">black</xsl:attribute>
    							<xsl:attribute name="border-bottom-width">thin</xsl:attribute>    
    							<fo:table-cell height="5mm" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>
    							<fo:table-cell padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    						</fo:table-row>
    					</fo:table-body>
    				</fo:table>
    
    			</fo:static-content>		
    			
    			<fo:static-content flow-name="region-after-odd">
    				
    				<fo:table table-layout="fixed" inline-progression-dimension="100%">
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-body>
    						<fo:table-row>
    							<xsl:attribute name="border-top-style">solid</xsl:attribute>
    							<xsl:attribute name="border-top-color">black</xsl:attribute>
    							<xsl:attribute name="border-top-width">thin</xsl:attribute>    
    							<fo:table-cell number-columns-spanned="3" height="5mm" padding-before="2pt">
    			
    							</fo:table-cell>
    			
    						</fo:table-row>
    						<fo:table-row>
    							<fo:table-cell height="5mm" number-columns-spanned="6" padding-before="2pt">
    							</fo:table-cell>
    						</fo:table-row>
    						<fo:table-row>
    							<fo:table-cell number-columns-spanned="2" height="5mm" padding-before="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>
    							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
    								<fo:block text-align="center"
    									font-size="11pt" font-weight="bold" space-after.conditionality="retain">
    									<xsl:call-template name="security"/>
    								</fo:block>
    							</fo:table-cell>
    							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
    			
    							</fo:table-cell>
    						</fo:table-row>
    					</fo:table-body>
    				</fo:table>
    				
    			</fo:static-content>		
    			
    			<fo:static-content flow-name="region-before-even">
    				<fo:table table-layout="fixed" inline-progression-dimension="100%">
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-body>
    						<fo:table-row>
    							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
    								<fo:block text-align="start" font-size="11pt" font-weight="bold">
    									<xsl:value-of select="$pmcode"/>				
    								</fo:block>
    							</fo:table-cell>
    			
    							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
    								<fo:block text-align="center"
    									font-size="11pt" font-weight="bold" space-after.conditionality="retain">
    									<xsl:call-template name="security"/>
    								</fo:block>    			
    							</fo:table-cell>
    							<!--S1000D, Section 6.2.1, para 2.4.1.1 Publication module code
    								The publication module code for the complete publication must be located in the header. The
    								publication module code is located in the top outside corner and presented in 11 pt bold, aligned
    								to the outer type limit.-->
    							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
    								<xsl:text>  </xsl:text>
    							</fo:table-cell>							
    						</fo:table-row>
    						<fo:table-row>
    							<fo:table-cell height="5mm" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>
    							<fo:table-cell padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    						</fo:table-row>
    						<fo:table-row>
    							<xsl:attribute name="border-bottom-style">solid</xsl:attribute>
    							<xsl:attribute name="border-bottom-color">black</xsl:attribute>
    							<xsl:attribute name="border-bottom-width">thin</xsl:attribute>    
    							<fo:table-cell height="5mm" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>
    							<fo:table-cell padding-after="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>				
    						</fo:table-row>
    					</fo:table-body>
    				</fo:table>
    			</fo:static-content>
    			<fo:static-content flow-name="region-after-even">
    				<fo:table table-layout="fixed" inline-progression-dimension="100%">
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-column column-width="16.7%"/>
    					<fo:table-body>
    						<fo:table-row>
    							<xsl:attribute name="border-top-style">solid</xsl:attribute>
    							<xsl:attribute name="border-top-color">black</xsl:attribute>
    							<xsl:attribute name="border-top-width">thin</xsl:attribute>    
    			
    							<fo:table-cell number-columns-spanned="3" height="5mm" padding-before="2pt">
    							</fo:table-cell>
    							<fo:table-cell number-columns-spanned="3" padding-before="2pt">
    			
    							</fo:table-cell>
    					</fo:table-row>
    						<fo:table-row>
    							<fo:table-cell height="5mm" number-columns-spanned="6" padding-before="2pt">
    							</fo:table-cell>
    						</fo:table-row>
    						<fo:table-row>
    							<fo:table-cell number-columns-spanned="2" height="5mm" padding-before="2pt">
    							</fo:table-cell>
    
    							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
    								<fo:block text-align="center"
    									font-size="11pt" font-weight="bold" space-after.conditionality="retain">
    									<xsl:call-template name="security"/>
    								</fo:block>    
    							</fo:table-cell>
    							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
    								<fo:block>
    									<xsl:text> </xsl:text>
    								</fo:block>
    							</fo:table-cell>
    						</fo:table-row>
    					</fo:table-body>
    				</fo:table>
    			</fo:static-content>				
    
    	
    			<fo:flow flow-name="region-body" white-space-collapse="true">
    				<fo:marker marker-class-name="blank-page"> </fo:marker>
    				<fo:marker marker-class-name="end-of-dm"> </fo:marker>
    				<fo:block text-align="left" span="all">
    
    					<fo:block font-size="14pt" font-weight="bold" text-align="center" keep-with-next="auto"
    						break-before="page" span="all" margin-top="13pt" margin-bottom="14pt">
    					    <xsl:text>CHAPTER </xsl:text>
    					    <xsl:value-of select="count(preceding::pmEntry[@pmEntryType = 'pmt52'])+1"/>
    					</fo:block>
    				    <fo:block font-size="14pt" font-weight="bold" text-align="center" keep-with-next="auto"
    				        span="all" margin-top="13pt" margin-bottom="14pt">
    				        <xsl:apply-templates select="pmEntryTitle"/>
    				    </fo:block>
    				    
				    </fo:block>

    			</fo:flow>
    		</fo:page-sequence>

        </xsl:if>

    	<xsl:apply-templates select="*[not(self::pmEntryTitle)]"/>

    </xsl:template>

    <xsl:template match="pmEntryTitle">
        <xsl:if test="../@pmEntryType='pmt52'">
            <xsl:apply-templates/>
        </xsl:if>
    </xsl:template>

    <xsl:template match="pmEntry/dmRef">
        <xsl:apply-templates/>
    	<xsl:if test="dmRefIdent/dmCode/@infoCode='001'">
    		<xsl:call-template name="contents"/>
    	</xsl:if>
    </xsl:template>

    <xsl:template match="pmEntry/dmRef/dmRefIdent">
        <!-- 8/30/11 - kr - added dm seq no for page numbering -->
 
        <xsl:variable name="countAsPoint">
            <xsl:choose>
                <xsl:when test="../@changeType='add'">
                        <xsl:value-of select="1"/>
                </xsl:when>
                <xsl:otherwise>
                        <xsl:value-of select="0"/>
                </xsl:otherwise>
            </xsl:choose>               
        </xsl:variable>
        <xsl:variable name="countThisDm">
            <xsl:choose>
                <xsl:when test="../@changeType='add'">
                    <xsl:value-of select="0"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="1"/>
                </xsl:otherwise>
            </xsl:choose>               
        </xsl:variable>       
        <xsl:variable name="countAdds">
            <xsl:number count="dmRef[not(attribute::changeType='add')]" from="content"/>
<!--            <xsl:value-of select="format-number(count(preceding::dmRef[attribute::changeType='add'])+$countAsPoint,'00')"/>
-->
</xsl:variable>
        <xsl:variable name="dmSeq">
            <xsl:value-of select="format-number(count(preceding::dmRef[not(attribute::changeType='add')])+$countThisDm,'0000')"/>
        </xsl:variable>
        <xsl:variable name="dmCount">
            <xsl:value-of select="$dmSeq"/>
            <xsl:if test="$countAsPoint='1'">
                <xsl:text>.</xsl:text>
                <xsl:value-of select="$countAdds"/>
            </xsl:if>
            <xsl:text>-</xsl:text>
        </xsl:variable>
 
        <xsl:variable name="dmfile">
            <xsl:text>DMC-</xsl:text>
            <xsl:apply-templates select="dmCode"/>
            <xsl:text>_</xsl:text>
            <xsl:choose>
                <xsl:when test="issueInfo/@issueNumber">
                    <xsl:value-of select="issueInfo/@issueNumber"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>000</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>-</xsl:text>
            <xsl:choose>
                <xsl:when test="issueInfo/@inWork">
                    <xsl:value-of select="issueInfo/@inWork"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>01</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>_</xsl:text>
            <xsl:choose>
                <xsl:when test="language/@languageIsoCode">
                    <xsl:value-of select="language/@languageIsoCode"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>EN</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>-</xsl:text>
            <xsl:choose>
                <xsl:when test="language/@countryIsoCode">
                    <xsl:value-of select="language/@countryIsoCode"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>US</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>.xml</xsl:text>
        </xsl:variable>
        <!--	<xsl:result-document href="pmvars.txt">
            <xsl:number count="refdm" format="1"/>
            </xsl:result-document>
        -->
        <!-- 8/30/11 - kr - added page sequences here so dm sequence can be included in page numbering -->
        <xsl:variable name="dmdoc" select="document($dmfile)"/>
        <fo:page-sequence master-reference="body-pages" initial-page-number="1"
			force-page-count="end-on-even" format="1">
			<fo:static-content flow-name="region-before-odd">
				
				<fo:table table-layout="fixed" inline-progression-dimension="100%">
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-body>
						<fo:table-row>
							<fo:table-cell number-columns-spanned="2" height="5mm" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>
							<!-- From 3031 - Classification	
								The overall security classification assigned to a manual shall agree 
								with the highest security classification assigned to any data module within, and shall be marked 
								accordingly at the top and bottom of the front cover, title block page, and rear cover sheets. 
								The security classification markings for every page, including those for unclassified pages, 
								shall be bold and at the top and bottom center of each page.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Markings	
								Classification markings are not required at the top and bottom of pages in an unclassified manual.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Commercial classification	
								Commercial classification (value of attribute commercialClassificiation) shall not be presented.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
								<fo:block text-align="center"
									font-size="11pt" font-weight="bold" space-after.conditionality="retain">
								    <fo:inline text-transform="uppercase">
								        <xsl:apply-templates select="$dmdoc//security/@securityClassification"/>
								    </fo:inline>								</fo:block>
							</fo:table-cell>
							<!--S1000D, Section 6.2.1, para 2.4.1.1 Publication module code
							The publication module code for the complete publication must be located in the header. The
							publication module code is located in the top outside corner and presented in 11 pt bold, aligned
							to the outer type limit. -->
							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
								<fo:block text-align="end" font-size="11pt" font-weight="bold">
									<xsl:value-of select="$pmcode"/>
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
						<fo:table-row padding-after="2pt">
							<fo:table-cell height="5mm" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>
							<fo:table-cell padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
						</fo:table-row>
						<fo:table-row>
							<xsl:attribute name="border-bottom-style">solid</xsl:attribute>
							<xsl:attribute name="border-bottom-color">black</xsl:attribute>
							<xsl:attribute name="border-bottom-width">thin</xsl:attribute>    
							<fo:table-cell height="5mm" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>
							<fo:table-cell padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
						</fo:table-row>
					</fo:table-body>
				</fo:table>

			</fo:static-content>		
			
			<fo:static-content flow-name="region-after-odd">
				
				<fo:table table-layout="fixed" inline-progression-dimension="100%">
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-body>
						<fo:table-row>
							<xsl:attribute name="border-top-style">solid</xsl:attribute>
							<xsl:attribute name="border-top-color">black</xsl:attribute>
							<xsl:attribute name="border-top-width">thin</xsl:attribute>    
							<fo:table-cell number-columns-spanned="3" height="5mm" padding-before="2pt">
								<!-- From S1000D: For customized page-oriented publications an applicability annotation block is presented in the
									inside margin of the footer. 
									When the publication uses applicability annotations this must be included in the page identification.
									The applicability must be expressed, by project decision, with serial
									number of the Product, with an "Applicability" code or with a human readable expression.
									10 pt for 8.5 x 11, 9 pt for index cards
									From 3031: The project shall use the S1000D standard page-oriented presentation rules for the applicability annotation.
								-->
								<fo:block text-align="start">
									<xsl:text>Applicable to: </xsl:text>
									<xsl:choose>
										<xsl:when test="//pm">
											<xsl:apply-templates select="//pm/identAndStatusSection/pmStatus/applic"/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:apply-templates select="$dmdoc/dmodule/identAndStatusSection/dmStatus/applic"/>
										</xsl:otherwise>
									</xsl:choose>									
								</fo:block>
							</fo:table-cell>
							<fo:table-cell number-columns-spanned="3" padding-before="2pt">
								<fo:block text-align="end" font-size="11pt" font-weight="bold" space-after="8pt">
									<xsl:apply-templates select="$dmdoc/dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>											
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
						<fo:table-row>
							<fo:table-cell height="5mm" number-columns-spanned="6" padding-before="2pt">
								<fo:block text-align="center"
									font-size="11pt" font-weight="bold" wrap-option="no-wrap" overflow="hidden">
									<fo:retrieve-marker retrieve-position="last-starting-within-page" 
										retrieve-class-name="end-of-dm"/>
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
						<fo:table-row>
							<fo:table-cell number-columns-spanned="2" height="5mm" padding-before="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>
							<!-- From 3031 - Classification	
								The overall security classification assigned to a manual shall agree 
								with the highest security classification assigned to any data module within, and shall be marked 
								accordingly at the top and bottom of the front cover, title block page, and rear cover sheets. 
								The security classification markings for every page, including those for unclassified pages, 
								shall be bold and at the top and bottom center of each page.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Markings	
								Classification markings are not required at the top and bottom of pages in an unclassified manual.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Commercial classification	
								Commercial classification (value of attribute commercialClassificiation) shall not be presented.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
								<fo:block space-after="8pt" text-align="center"
									font-size="11pt" font-weight="bold">
								    <fo:inline text-transform="uppercase">
								        <xsl:apply-templates select="$dmdoc//security/@securityClassification"/>
								    </fo:inline>		
								</fo:block>
							</fo:table-cell>
							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
								<fo:block text-align="end" font-size="11pt" font-weight="bold">
									<xsl:text>Page </xsl:text>
									<xsl:value-of select="$dmCount"/>
									<fo:page-number/>
									<fo:retrieve-marker retrieve-position="last-starting-within-page"
										retrieve-class-name="blank-page"/>
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
					</fo:table-body>
				</fo:table>
				
			</fo:static-content>		
			
			<fo:static-content flow-name="region-before-even">
				<fo:table table-layout="fixed" inline-progression-dimension="100%">
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-body>
						<fo:table-row>
							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
								<fo:block text-align="start" font-size="11pt" font-weight="bold">
									<xsl:value-of select="$pmcode"/>				
								</fo:block>
							</fo:table-cell>
							<!-- From 3031 - Classification	
								The overall security classification assigned to a manual shall agree 
								with the highest security classification assigned to any data module within, and shall be marked 
								accordingly at the top and bottom of the front cover, title block page, and rear cover sheets. 
								The security classification markings for every page, including those for unclassified pages, 
								shall be bold and at the top and bottom center of each page.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Markings	
								Classification markings are not required at the top and bottom of pages in an unclassified manual.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Commercial classification	
								Commercial classification (value of attribute commercialClassificiation) shall not be presented.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
								<fo:block text-align="center"
									font-size="11pt" font-weight="bold">
								    <fo:inline text-transform="uppercase">
								        <xsl:apply-templates select="$dmdoc//security/@securityClassification"/>
								    </fo:inline>	
								    </fo:block>
							</fo:table-cell>
							<!--S1000D, Section 6.2.1, para 2.4.1.1 Publication module code
								The publication module code for the complete publication must be located in the header. The
								publication module code is located in the top outside corner and presented in 11 pt bold, aligned
								to the outer type limit.-->
							<fo:table-cell number-columns-spanned="2" padding-after="2pt">
								<xsl:text>  </xsl:text>
							</fo:table-cell>							
						</fo:table-row>
						<fo:table-row>
							<fo:table-cell height="5mm" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>
							<fo:table-cell padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
						</fo:table-row>
						<fo:table-row>
							<xsl:attribute name="border-bottom-style">solid</xsl:attribute>
							<xsl:attribute name="border-bottom-color">black</xsl:attribute>
							<xsl:attribute name="border-bottom-width">thin</xsl:attribute>    
							<fo:table-cell height="5mm" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
							<fo:table-cell number-columns-spanned="4" padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>
							<fo:table-cell padding-after="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>				
						</fo:table-row>
					</fo:table-body>
				</fo:table>
			</fo:static-content>
			<fo:static-content flow-name="region-after-even">
				<fo:table table-layout="fixed" inline-progression-dimension="100%">
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-column column-width="16.7%"/>
					<fo:table-body>
						<fo:table-row>
							<xsl:attribute name="border-top-style">solid</xsl:attribute>
							<xsl:attribute name="border-top-color">black</xsl:attribute>
							<xsl:attribute name="border-top-width">thin</xsl:attribute>    
							<!-- From S1000D: For customized page-oriented publications an applicability annotation block is presented in the
								inside margin of the footer. 
								When the publication uses applicability annotations this must be included in the page identification.
								The applicability must be expressed, by project decision, with serial
								number of the Product, with an "Applicability" code or with a human readable expression.
								10 pt for 8.5 x 11, 9 pt for index cards
								From 3031: The project shall use the S1000D standard page-oriented presentation rules for the applicability annotation.
							-->
							<fo:table-cell number-columns-spanned="3" height="5mm" padding-before="2pt">
								<fo:block text-align="start" font-size="11pt" font-weight="bold" space-after="8pt">
									<xsl:apply-templates select="$dmdoc/dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>
								</fo:block>
							</fo:table-cell>
							<fo:table-cell number-columns-spanned="3" padding-before="2pt">
								<fo:block text-align="end">
									<xsl:text>Applicable to: </xsl:text>
									<xsl:choose>
										<xsl:when test="//pm">
											<xsl:apply-templates select="//pm/identAndStatusSection/pmStatus/applic"/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:apply-templates select="$dmdoc/dmodule/identAndStatusSection/dmStatus/applic"/>
										</xsl:otherwise>
									</xsl:choose>									
								</fo:block>
							</fo:table-cell>
					</fo:table-row>
						<fo:table-row>
							<fo:table-cell height="5mm" number-columns-spanned="6" padding-before="2pt">
								<fo:block text-align="center"
									font-size="11pt" font-weight="bold" wrap-option="no-wrap" overflow="hidden">
									<fo:retrieve-marker retrieve-position="last-starting-within-page"
										retrieve-class-name="end-of-dm"/>
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
						<fo:table-row>
							<fo:table-cell number-columns-spanned="2" height="5mm" padding-before="2pt">
								<fo:block text-align="start" font-size="11pt" font-weight="bold">
									<xsl:text>Page </xsl:text>
								    <xsl:value-of select="$dmCount"/>
									<fo:page-number/>
								</fo:block>
							</fo:table-cell>
							<!-- From 3031 - Classification	
								The overall security classification assigned to a manual shall agree 
								with the highest security classification assigned to any data module within, and shall be marked 
								accordingly at the top and bottom of the front cover, title block page, and rear cover sheets. 
								The security classification markings for every page, including those for unclassified pages, 
								shall be bold and at the top and bottom center of each page.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Markings	
								Classification markings are not required at the top and bottom of pages in an unclassified manual.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<!-- From 3031 - Commercial classification	
								Commercial classification (value of attribute commercialClassificiation) shall not be presented.	
								S1000D Chapter 6.2.1 paragraph 2.4.2.
							-->
							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
								<fo:block space-after="8pt" text-align="center"
									font-size="11pt" font-weight="bold">
								    <fo:inline text-transform="uppercase">
								        <xsl:apply-templates select="$dmdoc//security/@securityClassification"/>
								    </fo:inline>
								</fo:block>
							</fo:table-cell>
							<fo:table-cell number-columns-spanned="2" padding-before="2pt">
								<fo:block>
									<xsl:text> </xsl:text>
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
					</fo:table-body>
				</fo:table>
			</fo:static-content>				

	
			<fo:flow flow-name="region-body" white-space-collapse="true">
				<fo:marker marker-class-name="blank-page"> </fo:marker>
				<fo:marker marker-class-name="end-of-dm"> </fo:marker>
				<fo:block text-align="left" span="all">
					<xsl:attribute name="id">
						<!-- 8/19/11 - KR - added id for dm references in pubs -->
					    <xsl:apply-templates select="$dmdoc/dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>
<!--
					    <xsl:text>_</xsl:text>
					    <xsl:value-of select="$dmSeq"/>
-->
</xsl:attribute>
					<!--s1000d_Iss_4_0_1_r1.pdf, Section 6.2.2, para 2.3.2, Table 2 Order and Typography of headings 
						Order Layout element Point			Typestyle 		Live matter Numbered
						size/Leading		
						1 	  Centerhead No. 1 14/16 pt 	Bold 	  		Centered 	No
						2 	  Centerhead No. 2 14/16 pt 	Bold, italic 	Centered 	No
						
						s1000d_Iss_4_0_1_r1.pdf, Section 6.2.2, para 2.3.2, Table 3 Leadings to adjacent headings and text paragraphs:
						Order Layout element 	Leading to		Leading to a		Leading text	Leading table
						next lower		follow-on text 		paragraph to	footer end
						level of 		paragraph			the heading		line to the
						heading												heading
						1 	  Centerhead No. 1 	28 pt/10 mm 	17 pt/6 mm 			27 pt 			35 pt
						Footnote to Table 3:  The leadings are the leadings between the baselines of the components-->
					
					<!--the space above Centerhead No 1 (margin-top) is thus calculated as: 
						Leading text paragraph to the heading (27pt) minus Centerhead No 1 point size (14pt) = 13pt
						the space below Centerhead No 1 (margin-bottom) is thus calcualted as: 
						Leading to next lower level of heading (28pt) minus CenterHead No 2 point size (14pt) = 14pt			
					-->
					<!--MIL-STD-3031A, para 5.21.1.9:
						The element <dmTitle> shall be used and shall contain the title of the referenced data module.-->
					<fo:block font-size="14pt" font-weight="bold" text-align="center" keep-with-next="auto"
						break-before="page" span="all" margin-top="13pt" margin-bottom="14pt">
						<xsl:apply-templates select="$dmdoc/dmodule/identAndStatusSection/dmAddress//dmTitle"></xsl:apply-templates>
					</fo:block>
		<!-- 8/19/11 - KR - seems like excess code here 
					<fo:block id="{generate-id(..)}" span="all">
						<xsl:attribute name="space-before">7pt</xsl:attribute>
						<xsl:attribute name="space-after">7pt</xsl:attribute>
						<xsl:attribute name="space-after.conditionality">retain</xsl:attribute>
					</fo:block>
		-->
				    <xsl:apply-templates select="$dmdoc" mode="pm"/>

				</fo:block>
				<fo:block>
					<!-- From 3031, A blank page shall be assigned a number, but it shall appear on the preceding or following page. -->
					<fo:marker marker-class-name="blank-page">
						<xsl:text> / blank</xsl:text>
					</fo:marker>
				</fo:block>
				<fo:block>
					<!-- From 3031: The statement "End of [insert data module title]" shall appear below the last item described in the column for each figure of the tabular lists in the repair parts list and the special tools lists. -->
					<!-- From 3031: The words "End of [data module title]" shall be placed at the end of every data module. -->
					<fo:marker marker-class-name="end-of-dm">
						<xsl:text>End of </xsl:text>
						<xsl:apply-templates select="$dmdoc//identAndStatusSection//dmTitle"/>
					</fo:marker>
				</fo:block>
			</fo:flow>
		</fo:page-sequence>
    </xsl:template>


    <xsl:template match="pmEntry/pmRef/pmRefIdent">
        <xsl:variable name="pmfile">
            <xsl:text>PMC-</xsl:text>
            <xsl:apply-templates select="pmCode"/>
            <xsl:text>_</xsl:text>
            <xsl:choose>
                <xsl:when test="issueInfo/@issueNumber">
                    <xsl:value-of select="issueInfo/@issueNumber"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>000</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>-</xsl:text>
            <xsl:choose>
                <xsl:when test="issueInfo/@inWork">
                    <xsl:value-of select="issueInfo/@inWork"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>01</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>_</xsl:text>
            <xsl:choose>
                <xsl:when test="language/@languageIsoCode">
                    <xsl:value-of select="language/@languageIsoCode"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>EN</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>-</xsl:text>
            <xsl:choose>
                <xsl:when test="language/@countryIsoCode">
                    <xsl:value-of select="language/@countryIsoCode"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>US</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>.xml</xsl:text>
        </xsl:variable>
        <xsl:apply-templates select="document($pmfile)" mode="pm"/>
    </xsl:template>


</xsl:stylesheet>


/ gopher://khzae.net/0/s1kd/links/projects/3031/sample/PhunGun/CSDB/FO-3031-A00-S1000DGUN-PUBLICATION_001-00_EN-US.xsl
Styles: Light Dark Classic