/ .. / / -> download
<?xml version="1.0" encoding="utf-8"?>
<!-- Fragment document type declaration subset:
	Arbortext, Inc., 1988-2005, v.4002
	<!DOCTYPE xsl:stylesheet>
-->
<!-- 8/19/11 - KR - Corrected syntax of xsl:variable to remove the end tag -->
<!-- 8/20/11 - kr - Corrected ids on tools and remarks and added links -->

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fo="http://www.w3.org/1999/XSL/Format">

	<!--MIL-STD-3031A, para 5.94.3.1.1 General.
	...The MAC shall be prepared using the
	maintenance planning schema and the <mainAllocation> branch.-->

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

	<!--MIL-STD-3031A, para 5.35.1.1 Use of the element <maintPlanning>
		The element <maintPlanning> allows for several branch options. Only the use of
		<commonInfo>, <maintAllocation>, <toolsList>, and <remarksList> is allowed.-->
	
	<xsl:template match="maintAllocation">
		<fo:block span="all">
			<xsl:if test="@id">
				<xsl:attribute name="id">
					<xsl:value-of disable-output-escaping="no" select="@id"/>
				</xsl:attribute>
			</xsl:if>
<!--		S1000D, chap 6.2.2, para 2.8.1 Formal tables:			
			The table title line must be centered above the table head and be written in 10/11 pt italic. An			
			extra leading of 12 pt must be added before the table title line and 2 pt after. The caption			
			"Table" followed by the number of the table, starting from "1" within each data module, must be			
			separated from the title itself by two spaces.

			S1000D, chap 3.9.5.2.1.6, para 2.1: 			
			Table titles must be written in sentence case and have no period [.] at the end.-->
						
			<fo:table-and-caption span="all">
				<fo:table-caption>
					<fo:block font-size="10pt" font-weight="bold"
						keep-with-previous.within-column="always"
						keep-with-previous.within-page="always" space-after="10pt"
						space-before.maximum="12pt" space-before.minimum="8pt"
						space-before.optimum="10pt" span="all" text-align="center">
						<xsl:text disable-output-escaping="no">Table </xsl:text>
						<xsl:call-template name="number-tables"/>
						<xsl:text disable-output-escaping="no">  </xsl:text>
						<xsl:apply-templates select="title"> </xsl:apply-templates>
					</fo:block>
				</fo:table-caption>
				<fo:table width="7.0in" border-bottom="solid" border-bottom-width=".5pt"
					border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" border-top="solid" border-top-width=".5pt"
					font-size="8pt" margin-bottom="8pt" margin-left="3pt" margin-right="3pt"
					margin-top="8pt" padding-bottom="3pt" padding-left="3pt" padding-right="3pt"
					relative-position="static" space-after="12pt" space-before.maximum="14pt"
					space-before.minimum="12pt" space-before.optimum="12pt" span="all"
					table-layout="fixed" table-omit-header-at-break="false" text-align="left"
					white-space-treatment="preserve">
					<fo:table-column column-number="1" column-width="9%"/>
					<fo:table-column column-number="2" column-width="20%"/>
					<fo:table-column column-number="3" column-width="15%"/>
					<fo:table-column column-number="4" column-width="7%"/>
					<fo:table-column column-number="5" column-width="7%"/>
					<fo:table-column column-number="6" column-width="7%"/>
					<fo:table-column column-number="7" column-width="7%"/>
					<fo:table-column column-number="8" column-width="15%"/>
					<fo:table-column column-number="9" column-width="13%"/>		
					<xsl:choose>
						<xsl:when test="ancestor::dmodule//dmCode/@infoCode='916' and ancestor::dmodule//dmIdent/dmCode/@infoCodeVariant='A'">
							<xsl:call-template name="MAC-HEADER-2lvl"/>
						</xsl:when>
						<xsl:when test="ancestor::dmodule//dmCode/@infoCode='916' and ancestor::dmodule//dmIdent/dmCode/@infoCodeVariant='B'">
							<xsl:call-template name="AVIATION-MAC-HEADER"/>
						</xsl:when>
						<xsl:otherwise/>	
					</xsl:choose>
					<fo:table-body>
						<xsl:apply-templates select="maintAllocationGroup"/>
					</fo:table-body>
				</fo:table>
			</fo:table-and-caption>
		</fo:block>
	</xsl:template>

	<xsl:template name="MAC-HEADER-2lvl">
		<fo:table-header font-size="7pt" text-align="center">
			<fo:table-row>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>(1)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>(2)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>(3)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" number-columns-spanned="4" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block>(4)</fo:block>
					<fo:block>MAINTENANCE LEVEL</fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" column-number="8" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block>(5)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" column-number="9" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block>(6)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
			</fo:table-row>
			<!--MIL-STD-3031A, para 5.94.3.1.4 Maintenance Allocation Chart (MAC) format.
			The non-aviation MAC ... shall be prepared as follows:
			c. The maintenance level entry shall be as follows:
			(1) The non-aviation MAC maintenance level column shall be divided into two main
			headings, one for field and one for sustainment. Beneath the main headings there
			shall be four subheadings. Crew and maintainer shall be under field and below depot
			sustainment and depot shall be under sustainment.-->
			<fo:table-row>
				<!-- ROW for FIELD and SUSTAINMENT -->
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" number-columns-spanned="2" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block/>
					<fo:block>FIELD</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="6" number-columns-spanned="2" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block/>
					<fo:block>SUSTAINMENT</fo:block>
				</fo:table-cell>
				<!--		-->
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" column-number="9" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
			</fo:table-row>
			<!-- Bottom Row -->
			<fo:table-row>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="1" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>GROUP</fo:block>
					<fo:block>NUMBER</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="2" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block> </fo:block>
					<fo:block>COMPONENT/ASSEMBLY</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="3" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>MAINTENANCE</fo:block>
					<fo:block>FUNCTION</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" display-align="after" number-columns-spanned="1"
					number-rows-spanned="1" padding-bottom="2pt" padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>CREW</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="5" number-rows-spanned="1" padding-bottom="2pt" padding-top="2pt">
					<fo:block>MAIN-</fo:block>
					<fo:block>TAINER</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="6" number-rows-spanned="1" padding-bottom="2pt" padding-top="2pt">
					<fo:block>BELOW</fo:block>
					<fo:block>DEPOT</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="7" display-align="after" number-rows-spanned="1"
					padding-bottom="2pt" padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>DEPOT</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="8" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block>TOOLS AND</fo:block>
					<fo:block>EQUIPMENT</fo:block>
					<fo:block>REF CODE</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="9" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>REMARKS</fo:block>
					<fo:block>CODE</fo:block>
				</fo:table-cell>
			</fo:table-row>
			<!-- 4 levels of maintenance -->
			<fo:table-row>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" display-align="after" padding-bottom="2pt" padding-top="2pt"
					starts-row="false">
					<fo:block>C</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="5" display-align="after" padding-bottom="2pt" padding-top="2pt">
					<fo:block>F</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="6" display-align="after" padding-bottom="2pt" padding-top="2pt">
					<fo:block>H</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="7" display-align="after" padding-bottom="2pt" padding-top="2pt">
					<fo:block>D</fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-header>
	</xsl:template>
	
	<xsl:template name="AVIATION-MAC-HEADER">
		<fo:table-header font-size="7pt" text-align="center">
			<fo:table-row>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>(1)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>(2)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>(3)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" number-columns-spanned="4" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block>(4)</fo:block>
					<fo:block>MAINTENANCE LEVEL</fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" column-number="8" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block>(5)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" column-number="9" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block>(6)</fo:block>
					<fo:block> </fo:block>
				</fo:table-cell>
			</fo:table-row>
			<!--MIL-STD-3031A, para 5.94.3.1.4 Maintenance Allocation Chart (MAC) format.
				The ... aviation mac shall be prepared as follows:
				c. The maintenance level entry shall be as follows:
				(2) The aviation MAC maintenance level column shall be divided into two main
				headings, one for field and one for sustainment. Beneath the main headings there
				shall be four subheadings. Aviation Maintenance Company and Aviation Support
				Battalion shall be under field and theater aviation sustainment maintenance group
				and depot shall be under sustainment.-->
			<fo:table-row>
				<!-- ROW for FIELD and SUSTAINMENT -->
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" number-columns-spanned="2" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block/>
					<fo:block>FIELD</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="6" number-columns-spanned="2" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block/>
					<fo:block>SUSTAINMENT</fo:block>
				</fo:table-cell>
				<!--		-->
				<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" column-number="9" padding-bottom="4pt"
					padding-top="4pt">
					<fo:block/>
					<fo:block> </fo:block>
				</fo:table-cell>
			</fo:table-row>
			<!-- Bottom Row -->
			<fo:table-row>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="1" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>GROUP</fo:block>
					<fo:block>NUMBER</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="2" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block> </fo:block>
					<fo:block>COMPONENT/ASSEMBLY</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="3" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>MAINTENANCE</fo:block>
					<fo:block>FUNCTION</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" display-align="after" number-columns-spanned="1"
					number-rows-spanned="1" padding-bottom="2pt" padding-top="2pt">
					<fo:block>AMC</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="5" number-rows-spanned="1" padding-bottom="2pt" padding-top="2pt">
					<fo:block>ASB</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="6" number-rows-spanned="1" padding-bottom="2pt" padding-top="2pt">
					<fo:block>TASMG</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="7" display-align="after" number-rows-spanned="1"
					padding-bottom="2pt" padding-top="2pt">
					<fo:block>DEPOT</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="8" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block>TOOLS AND</fo:block>
					<fo:block>EQUIPMENT</fo:block>
					<fo:block>REF CODE</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="9" display-align="after" empty-cells="show"
					number-columns-spanned="1" number-rows-spanned="2" padding-bottom="2pt"
					padding-top="2pt">
					<fo:block> </fo:block>
					<fo:block>REMARKS</fo:block>
					<fo:block>CODE</fo:block>
				</fo:table-cell>
			</fo:table-row>
			<!-- 4 levels of maintenance -->
			<fo:table-row>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="4" display-align="after" padding-bottom="2pt" padding-top="2pt"
					starts-row="false">
					<fo:block>O</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="5" display-align="after" padding-bottom="2pt" padding-top="2pt">
					<fo:block>F</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="6" display-align="after" padding-bottom="2pt" padding-top="2pt">
					<fo:block>L</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="7" display-align="after" padding-bottom="2pt" padding-top="2pt">
					<fo:block>D</fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-header>
	</xsl:template>

	<xsl:template match="maintAllocationGroup">
		<!--MIL-STD-3031A, para 5.94.3.1.4 Maintenance Allocation Chart (MAC) format.
		The non-aviation MAC and aviation MAC shall be prepared as follows:
		b. The group number entry shall be entered, the nomenclature of the spare
		(component/assembly) shall be entered, and the maintenance function shall be listed in
		the MAC.-->
		<fo:table-row>
			<fo:table-cell border-left="solid black" border-left-width=".5pt" padding-after="4pt"
				padding-before="4pt">
				<fo:block space-after="2mm" space-before="2mm" start-indent="2mm" end-indent="2mm">
					<xsl:value-of select="groupNumber"/>
				</fo:block>
			</fo:table-cell>
			<xsl:choose>
				<xsl:when test="componentAssy">
					<xsl:apply-templates select="componentAssy[1]"/>
					<xsl:apply-templates select="maintQualifier[1]"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates select="componentAssyGroup[1]/componentAssy"/>
					<xsl:apply-templates select="componentAssyGroup[1]/maintQualifier[1]"/>
				</xsl:otherwise>
			</xsl:choose>
		</fo:table-row>
		<xsl:choose>
			<xsl:when test="componentAssy">
				<xsl:apply-templates select="maintQualifier[position()>1]"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="componentAssyGroup[1]/maintQualifier[position()>1]"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates select="componentAssyGroup[position()>1]"/>
	</xsl:template>

	<xsl:template match="componentAssy">
		<fo:table-cell border-left="solid black" border-left-width=".5pt" padding-after="4pt"
			padding-before="4pt" border-right-style="solid" border-right-width="0.5pt"
			keep-together.within-column="always">
			<fo:block space-after="2mm" space-before="2mm" start-indent="2mm" end-indent="2mm" linefeed-treatment="" >
				<xsl:apply-templates/>
			</fo:block>
		</fo:table-cell>
	</xsl:template>

	<xsl:template match="componentAssyGroup">
		<xsl:if test="preceding-sibling::componentAssyGroup">
			<fo:table-row>
				<fo:table-cell border-left="solid black" border-left-width=".5pt"
					padding-after="4pt" padding-before="4pt">
					<fo:block>
						<xsl:text> </xsl:text>
					</fo:block>
				</fo:table-cell>
				<xsl:apply-templates select="componentAssy[1]"/>
				<xsl:apply-templates select="maintQualifier[1]"/>
			</fo:table-row>
			<xsl:apply-templates select="maintQualifier[position()>1]"/>
		</xsl:if>
	</xsl:template>

	<xsl:template match="maintQualifier">
		<xsl:choose>
			<xsl:when test="preceding-sibling::maintQualifier">
				<fo:table-row>
					<fo:table-cell border-left="solid black" border-left-width=".5pt"
						padding-after="4pt" padding-before="4pt">
						<fo:block>
							<xsl:text> </xsl:text>
						</fo:block>
					</fo:table-cell>
					<fo:table-cell border-left="solid black" border-left-width=".5pt"
						padding-after="4pt" padding-before="4pt">
						<fo:block>
							<xsl:text> </xsl:text>
						</fo:block>
					</fo:table-cell>
					<xsl:call-template name="do-maintQualifier"/>
				</fo:table-row>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="do-maintQualifier"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="do-maintQualifier">
		<fo:table-cell border-left="solid black" border-left-width=".5pt" padding-after="4pt"
			padding-before="4pt">
			<fo:block text-align="left" space-after="2mm" space-before="2mm" start-indent="2mm"
				end-indent="2mm">
				<xsl:choose>
					<xsl:when test="normalize-space(maintFunction/@function)">
						<xsl:apply-templates select="child::maintFunction/@function"></xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<fo:block>
							<xsl:text> </xsl:text>
						</fo:block>
					</xsl:otherwise>
				</xsl:choose>
			</fo:block>
		</fo:table-cell>
		<!--MIL-STD-3031A, para 5.94.3.1.4 Maintenance Allocation Chart (MAC) format.
			The non-aviation MAC and aviation MAC shall be prepared as follows:
		d. A work time figure shall appear in the entry for the maintenance level authorized to
		perform the maintenance listed in the maintenance function.-->
		<fo:table-cell border-left="solid black" border-left-width=".5pt" padding-after="4pt"
			padding-before="4pt">
			<xsl:choose>
				<xsl:when test="normalize-space(maintLevelGroup/maintLevel/@maintLevelCode)">
					<xsl:choose>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml51'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml51']"/>
							</fo:block>
						</xsl:when>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml56'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml56']"/>
							</fo:block>
						</xsl:when>
						<xsl:otherwise>
							<fo:block>
								<xsl:text> </xsl:text>
							</fo:block>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<fo:block>
						<xsl:text> </xsl:text>
					</fo:block>
				</xsl:otherwise>
			</xsl:choose>
		</fo:table-cell>
		<fo:table-cell border-left="solid black" border-left-width=".5pt" padding-after="4pt"
			padding-before="4pt">
			<xsl:choose>
				<xsl:when test="normalize-space(maintLevelGroup/maintLevel/@maintLevelCode)">
					<xsl:choose>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml52'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml52']"/>
							</fo:block>
						</xsl:when>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml57'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml57']"/>
							</fo:block>
						</xsl:when>
						<xsl:otherwise>
							<fo:block>
								<xsl:text> </xsl:text>
							</fo:block>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<fo:block>
						<xsl:text> </xsl:text>
					</fo:block>
				</xsl:otherwise>
			</xsl:choose>
		</fo:table-cell>
		<fo:table-cell border-left="solid black" border-left-width=".5pt" padding-after="4pt"
			padding-before="4pt">
			<xsl:choose>
				<xsl:when test="normalize-space(maintLevelGroup/maintLevel/@maintLevelCode)">
					<xsl:choose>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml54'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml54']"/>
							</fo:block>
						</xsl:when>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml58'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml58']"/>
							</fo:block>
						</xsl:when>
						<xsl:otherwise>
							<fo:block>
								<xsl:text> </xsl:text>
							</fo:block>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<fo:block>
						<xsl:text> </xsl:text>
					</fo:block>
				</xsl:otherwise>
			</xsl:choose>
		</fo:table-cell>
		<fo:table-cell border-left="solid black" border-left-width=".5pt" padding-after="4pt"
			padding-before="4pt">
			<xsl:choose>
				<xsl:when test="normalize-space(maintLevelGroup/maintLevel/@maintLevelCode)">
					<xsl:choose>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml55'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml55']"/>
							</fo:block>
						</xsl:when>
						<xsl:when test="maintLevelGroup/maintLevel/@maintLevelCode='ml59'">
							<fo:block>
								<xsl:value-of select="maintLevelGroup/maintLevel[@maintLevelCode='ml59']"/>
							</fo:block>
						</xsl:when>
						<xsl:otherwise>
							<fo:block>
								<xsl:text> </xsl:text>
							</fo:block>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<fo:block>
						<xsl:text> </xsl:text>
					</fo:block>
				</xsl:otherwise>
			</xsl:choose>
		</fo:table-cell>
		<!--MIL-STD-3031A, para 5.94.3.1.4 Maintenance Allocation Chart (MAC) format.
			The non-aviation MAC and aviation MAC shall be prepared as follows:
			d.  Reference numbers for all required tools and test equipment shall be listed in the Tools and Equipment Reference
			Code entry of the MAC. These reference numbers shall correspond to the appropriate
			tools/test equipment listed in the tools and test equipment table.
			-->
		<fo:table-cell padding-after="4pt" padding-before="4pt" keep-together.within-column="always"
			border-left-style="solid" border-left-width="0.5pt" text-align="left">
			
				<xsl:choose>
					<xsl:when test="normalize-space(toolsRefs/internalRef/@internalRefId[1])">
						<fo:block span="all">
						<xsl:apply-templates select="toolsRefs/internalRef"/>
						<xsl:text> </xsl:text>
						<xsl:if test="following-sibling::internalRef">
							<xsl:text disable-output-escaping="no">, </xsl:text>
						</xsl:if>
						</fo:block>
					</xsl:when>
					<xsl:otherwise>
						<fo:block>
							<xsl:text> </xsl:text>
						</fo:block>
					</xsl:otherwise>
				</xsl:choose>			
		</fo:table-cell>
		<!--MIL-STD-3031A, para 5.94.3.1.4 Maintenance Allocation Chart (MAC) format.
			The non-aviation MAC and aviation MAC shall be prepared as follows:
			e. Reference letters for applicable remarks be listed in the Remarks Code entry of the MAC.
			These reference letters shall correspond to the appropriate remarks listed in the remarks
			table.-->
		<fo:table-cell padding-left="2pt" padding-after="4pt" padding-before="4pt"
			keep-together.within-column="always" border-left-style="solid" border-left-width="0.5pt"
			text-align="left">			
				<xsl:choose>
					<xsl:when test="normalize-space(remarksRefs/internalRef/@internalRefId[1])">
						<fo:block span="all">
						<xsl:apply-templates select="remarksRefs/internalRef"/>
						<xsl:text> </xsl:text>
						<xsl:if test="following-sibling::internalRef">
							<xsl:text disable-output-escaping="no">, </xsl:text>
						</xsl:if>
						</fo:block>
					</xsl:when>
					<xsl:otherwise>
						<fo:block>
							<xsl:text> </xsl:text>
						</fo:block>
					</xsl:otherwise>
				</xsl:choose>			
		</fo:table-cell>
	</xsl:template>

	<!--MIL-STD-3031A, para 5.48.1.14 Type of maintenance function – attribute function.
		Attribute values shall be used as defined in the following table. The attribute function and
		these attribute values are applicable to MACs only.
		TABLE XV. Attribute values – function.-->

	<!--MIL-STD-3031A, para 5.48.1.21 Maintenance level code – attribute maintLevelCode.
		Attribute values shall be used as defined in the following table.
		TABLE XXI. Attribute values – maintLevelcode.-->

	<!--MIL-STD-3031A, para 5.35.1.3 Use of the element <componentAssyGroup>
		The element <componentAssyGroup> shall be used when authoring component/assembly
		information.-->

	<xsl:template match="remarksRefs/internalRef | toolsRefs/internalRef">

		<xsl:call-template name="MACREF">
			<xsl:with-param name="IdString" select="@internalRefId"/>
		</xsl:call-template>
		<xsl:choose>
			<xsl:when test="following-sibling::*">
				<xsl:text disable-output-escaping="no">, </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text> </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
			
	</xsl:template>

	<xsl:template name="MACREF">
		<xsl:param name="IdString"/>
		<xsl:variable name="IdRef">
			<xsl:value-of disable-output-escaping="no" select="substring-before($IdString,' ')"/>
		</xsl:variable>
		<xsl:variable name="Remaining">
			<xsl:value-of disable-output-escaping="no" select="substring-after($IdString,' ')"/>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="string-length($IdRef)>0">
				<xsl:value-of disable-output-escaping="no" select="id($IdRef)"/>
				<xsl:if test="string-length($Remaining)>0">, <xsl:call-template name="MACREF">
						<xsl:with-param name="IdString" select="$Remaining"/>
					</xsl:call-template>
				</xsl:if>
			</xsl:when>
			<xsl:when test="string-length($IdString)>0">
				<fo:basic-link>
					<xsl:attribute name="internal-destination">
						<xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>											
						<xsl:value-of select="$IdString"/>
					</xsl:attribute>
					<xsl:for-each select="key('id',($IdString))">
						<xsl:value-of select="."/>
					</xsl:for-each>
<!--					
				<xsl:value-of disable-output-escaping="no" select="id($IdString)"/>
-->
				</fo:basic-link>
			</xsl:when>
		</xsl:choose>

	</xsl:template>

	<xsl:template match="maintAllocation/title | toolsList/title | remarksList/title">
		<xsl:apply-templates select="node()"/>
	</xsl:template>

<!--MIL-STD-3031A, para 5.94.3.1.5 Tools and test equipment requirements.
	A tabular list of all tools and test equipment, both special and common, required to maintain the
	equipment shall be prepared, as applicable. The column headings shall be:
	a. Column 1 – "Tools of test equipment reference code"
	b. Column 2 – "Maintenance level"
	c. Column 3 – "Nomenclature"
	d. Column 4 – "National stock number"
	e. Column 5 – "Tool number"-->
	<xsl:template match="toolsList">
		<fo:table-and-caption span="all">
			<fo:table-caption>
				<fo:block font-size="10pt" font-weight="bold"
					keep-with-previous.within-column="always"
					keep-with-previous.within-page="always" space-after="10pt"
					space-before.maximum="12pt" space-before.minimum="8pt"
					space-before.optimum="10pt" span="all" text-align="center">
					<xsl:text disable-output-escaping="no">Table </xsl:text>
					<xsl:call-template name="number-tables"/>
					<xsl:text disable-output-escaping="no">  </xsl:text>
					<xsl:apply-templates select="title"/>
				</fo:block>
			</fo:table-caption>
			<fo:table border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
				border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
				border-top="solid" border-top-width=".5pt" font-size="8pt" margin-bottom="8pt"
				margin-left="3pt" margin-right="3pt" margin-top="8pt" padding-bottom="3pt"
				padding-left="3pt" padding-right="3pt" relative-position="static" space-after="12pt"
				space-before.maximum="14pt" space-before.minimum="12pt" space-before.optimum="12pt"
				span="all" table-layout="fixed" table-omit-header-at-break="false" text-align="left"
				white-space-treatment="preserve">
				<fo:table-column column-number="1" column-width="15%"/>
				<fo:table-column column-number="2" column-width="15%"/>
				<fo:table-column column-number="3" column-width="40%"/>
				<fo:table-column column-number="4" column-width="16%"/>
				<fo:table-column column-number="5" column-width="14%"/>
				<xsl:call-template name="TOOLSLIST-HEADER"/>
				<fo:table-body>
					<xsl:apply-templates select="toolsListGroup"/>
				</fo:table-body>
			</fo:table>
		</fo:table-and-caption>
	</xsl:template>

	<xsl:template name="TOOLSLIST-HEADER">
		<fo:table-header font-size="7pt" font-weight="bold" text-align="center">
			<fo:table-row>
				<fo:table-cell border-bottom-style="solid" border-bottom-width=".75pt"
					border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>TOOLS OF TEST</fo:block>
					<fo:block>EQUIPMENT</fo:block>
					<fo:block>REF CODE</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom-style="solid" border-bottom-width=".75pt"
					border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block> </fo:block>
					<fo:block>MAINTENANCE</fo:block>
					<fo:block>LEVEL</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom-style="solid" border-bottom-width=".75pt"
					border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block> </fo:block>
					<fo:block> </fo:block>
					<fo:block>NOMENCLATURE</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom-style="solid" border-bottom-width=".75pt"
					border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block>NATIONAL</fo:block>
					<fo:block>STOCK</fo:block>
					<fo:block>NUMBER</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom-style="solid" border-bottom-width=".75pt"
					border-left="solid" border-left-width=".5pt" border-right="solid"
					border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
					<fo:block> </fo:block>
					<fo:block>TOOL</fo:block>
					<fo:block>NUMBER</fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-header>
	</xsl:template>

	<xsl:template match="toolsListGroup">
		<fo:table-row>
			<xsl:apply-templates select="toolsListCode"/>
		</fo:table-row>
	</xsl:template>

	<xsl:template match="toolsListCode">
		<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
			border-right-width=".5pt" column-number="1" padding-bottom="4pt" padding-top="4pt"
			starts-row="true" text-align="center">
			<fo:block span="all" text-align="center">
				<!-- 8/20/11 - kr - added id for refs -->
				<xsl:if test="@id">
					<xsl:attribute name="id">
						<xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>											
						<xsl:value-of disable-output-escaping="no" select="@id"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:apply-templates select="node()"/>
			</fo:block>
		</fo:table-cell>
		<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
			border-right-width=".5pt" column-number="2" padding-bottom="4pt" padding-top="4pt"
			starts-row="false" text-transform="uppercase">
			<!--MIL-STD-3031A, para 5.48.1.21 Maintenance level code – attribute maintLevelCode.
			Attribute values shall be used as defined in the following table.
			TABLE XXI. Attribute values – maintLevelcode.-->
			<fo:block span="all" text-align="center">
				<xsl:choose>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml51']"
						>C</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml52']"
						>F</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml53']"
						>L</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml54']"
						>H</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml55']"
						>D</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml56']"
						>O</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml57']"
						>F</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml58']"
						>L</xsl:when>
					<xsl:when test="following-sibling::maintLevel[@maintLevelCode='ml59']"
						>D</xsl:when>
					<xsl:otherwise>
						<xsl:value-of disable-output-escaping="no"
							select="following-sibling::maintLevel[@maintLevelCode]"/>
					</xsl:otherwise>
				</xsl:choose>
			</fo:block>
		</fo:table-cell>
		<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
			border-right-width=".5pt" column-number="3" padding-bottom="4pt" padding-top="4pt"
			starts-row="false">
			<fo:block>
				<xsl:value-of disable-output-escaping="no" select="following-sibling::name"/>
			</fo:block>
		</fo:table-cell>
		<!--MIL-STD-3031A, para 5.37.1.14 North Atlantic Treaty Organization (NATO) stock number.
		The element <natoStockNumber> shall be used for all stocked parts that have an NSN.-->
		<!--MIL-STD-3031A, para 5.37.1.15 National Stock Number (NSN) optional attributes.
		The following attributes of the element <natoStockNumber> shall be used:
			a. natoSupplyClass shall contain the four-digit Federal Supply Classification (FSC).
			b. natoCodificationBureau shall contain the first two digits of the National Item
			Identification Number (NIIN).
			c. natoItemIdentNumberCore shall contain the final seven digits of the NIIN.-->
		<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
			border-right-width=".5pt" column-number="4" padding-bottom="4pt" padding-top="4pt">
			<fo:block>
				<xsl:call-template name="NSN-VALUE">
					<xsl:with-param name="Fsc"
						select="following-sibling::natoStockNumber/@natoSupplyClass"/>
					<xsl:with-param name="Niin-2"
						select="following-sibling::natoStockNumber/@natoCodificationBureau"/>
					<xsl:with-param name="Niin-7"
						select="following-sibling::natoStockNumber/@natoItemIdentNumberCore"/>
				</xsl:call-template>
			</fo:block>
		</fo:table-cell>
		<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
			border-right-width=".5pt" column-number="5" ends-row="true" padding-bottom="4pt"
			padding-top="4pt">
			<fo:block hyphenate="true">
				<xsl:value-of disable-output-escaping="no"
					select="following-sibling::toolRef/@toolNumber"/>
			</fo:block>
		</fo:table-cell>
	</xsl:template>

	<xsl:template name="NSN-VALUE">
		<xsl:param name="Fsc"/>
		<xsl:param name="Niin-2"/>
		<xsl:param name="Niin-7"/>
		<!-- 8/19/11 - KR - Corrected syntax of xsl:variable to remove the end tag -->
		<xsl:variable name="Niin-7-3" select="substring($Niin-7,1,3)"/>
		<xsl:variable name="Niin-7-4" select="substring($Niin-7,4,4)"/>
		
		<xsl:choose>
			<xsl:when test="string-length($Fsc)+string-length($Niin-2)=0"> </xsl:when>
			<xsl:when
				test="string-length($Fsc)>4 or not(contains('0123456789',substring($Niin-2,1,1)))">
				<xsl:value-of disable-output-escaping="no" select="$Fsc"/>
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-2)"/>
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-7)"/>
			</xsl:when>
			<xsl:when test="not(contains($Niin-2,'-'))">
				<xsl:value-of disable-output-escaping="no" select="$Fsc"/>
				<xsl:text disable-output-escaping="no">–</xsl:text>
				<!--add a en dash after Fsc-->
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-2)"/>
				<xsl:text disable-output-escaping="no">–</xsl:text>
				<!--add a en dash after Niin-2-->
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-7-3)"/>
				<xsl:text disable-output-escaping="no">–</xsl:text>
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-7-4)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of disable-output-escaping="no" select="$Fsc"/>
				<xsl:text disable-output-escaping="no">-</xsl:text>
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-2)"/>
				<xsl:text disable-output-escaping="no">-</xsl:text>
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-7-3)"/>
				<xsl:text disable-output-escaping="no">-</xsl:text>
				<xsl:value-of disable-output-escaping="no" select="normalize-space($Niin-7-4)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--MIL-STD-3031A, para 5.94.3.1.7 Remarks.
	Remarks pertinent to maintenance functions shall be prepared, as applicable. The column
	headings shall be:
	a. Column 1 – "Remarks code"
	b. Column 2 – "Remarks"-->
	<xsl:template match="remarksList">
		<fo:block span="all">

			<fo:table-and-caption span="all">
				<fo:table-caption>
					<fo:block font-size="10pt" font-weight="bold"
						keep-with-previous.within-column="always"
						keep-with-previous.within-page="always" space-after="10pt"
						space-before.maximum="12pt" space-before.minimum="8pt"
						space-before.optimum="10pt" span="all" text-align="center">
						<xsl:text disable-output-escaping="no">Table </xsl:text>
						<xsl:call-template name="number-tables"/>
						<xsl:text disable-output-escaping="no">  </xsl:text>
						<xsl:apply-templates select="title"/>
					</fo:block>
				</fo:table-caption>
				<fo:table border-bottom="solid" border-bottom-width=".5pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					border-top="solid" border-top-width=".5pt" font-size="8pt" margin-bottom="8pt"
					margin-left="3pt" margin-right="3pt" margin-top="8pt" padding-bottom="3pt"
					padding-left="3pt" padding-right="3pt" relative-position="static"
					space-after="12pt" space-before.maximum="14pt" space-before.minimum="12pt"
					space-before.optimum="12pt" span="all" table-layout="fixed"
					table-omit-header-at-break="false" text-align="left"
					white-space-treatment="preserve">
					<fo:table-column column-number="1" column-width="15%"/>
					<fo:table-column column-number="2" column-width="85%"/>
					<xsl:call-template name="REMARKSLIST-HEADER"/>
					<fo:table-body>
						<xsl:apply-templates select="remarksGroup"/>
					</fo:table-body>
				</fo:table>
			</fo:table-and-caption>
		</fo:block>
	</xsl:template>

	<xsl:template name="REMARKSLIST-HEADER">
		<fo:table-header font-size="7pt" font-weight="bold" text-align="center">
			<fo:table-row>
				<fo:table-cell border-bottom="solid" border-bottom-width=".75pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="1" padding-bottom="4pt" padding-top="4pt">
					<fo:block>REMARKS</fo:block>
					<fo:block>CODE</fo:block>
				</fo:table-cell>
				<fo:table-cell border-bottom="solid" border-bottom-width=".75pt" border-left="solid"
					border-left-width=".5pt" border-right="solid" border-right-width=".5pt"
					column-number="2" padding-bottom="4pt" padding-top="4pt">
					<fo:block> </fo:block>
					<fo:block>REMARKS</fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-header>
	</xsl:template>

	<xsl:template match="remarksGroup">
		<fo:table-row>
			<xsl:apply-templates select="remarkCode"/>
		</fo:table-row>
	</xsl:template>


	<xsl:template match="remarksGroup/remarkCode">
		<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
			border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
			<fo:block span="all" text-align="center">
				<!-- 8/20/11 - kr - Add id -->
				<xsl:if test="@id">
					<xsl:attribute name="id">
						<xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>											
						<xsl:value-of disable-output-escaping="no" select="@id"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:apply-templates select="node()"/>
			</fo:block>
		</fo:table-cell>
		<fo:table-cell border-left="solid" border-left-width=".5pt" border-right="solid"
			border-right-width=".5pt" padding-bottom="4pt" padding-top="4pt">
			<fo:block span="all">
				<xsl:apply-templates select="following-sibling::remarks[1]"/>
			</fo:block>
		</fo:table-cell>
	</xsl:template>

	<xsl:template match="remarksGroup/remarks">
		<xsl:apply-templates select="node()"> </xsl:apply-templates>
	</xsl:template>

</xsl:stylesheet>


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