<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:agile="http://www.oracle.com/webfolder/technetwork/xml/plm/2013/09/">
	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<!-- Template to create the XML structure if the CO contains atleast one GLMS impacted affected item -->
		<xsl:variable name="catflag">
			<xsl:call-template name="GLMSItemTemplate"/>
		</xsl:variable>
		<xsl:if test="$catflag='true'">
			<xsl:apply-templates select="agile:AgileData/agile:ChangeOrders/agile:CoverPage"/>
		</xsl:if>
		<xsl:if test="$catflag='false'">
			<xsl:element name="IGNORE">
				<xsl:text>Change not relevant to GLMS</xsl:text>
			</xsl:element>
		</xsl:if>
	</xsl:template>
	<!-- Template to check if the CO contains atleast one GLMS impacted affected item -->
	<xsl:template name="GLMSItemTemplate">
		<xsl:value-of select="count(agile:AgileData/agile:ChangeOrders/agile:AffectedItems[(
							(agile:ItemType='Part') and 
									(agile:ItemCategory=('Internal Use Labels|Label Stock','Internal Use Labels|Labels','Product Labeling|Japan Label',
									'Product Labeling|Korea Label','Product Labeling|Labeling KIT','Product Labeling|Labels',
									'Electrical|FRU Assembly','Electro-Mechanical|FRU Assembly','Mechanical|FRU Assembly','Network|FRU Assembly','Vision|FRU Assembly')
									)
							) or (
							(agile:ItemType='Device Identifier')
							)]) &gt; 0"/>
	</xsl:template>
	
	<!-- Template to check if the BOM component contains atleast one GLMS impacted categories -->
	<xsl:template name="GLMSCompTemplate">	
			<xsl:value-of select="count(agile:RedlinedBOMRow/agile:ItemCategory=('Internal Use Labels|Label Stock','Internal Use Labels|Labels','Product Labeling|Japan Label',
					'Product Labeling|Korea Label','Product Labeling|Labeling KIT','Product Labeling|Labels',
					'Electrical|FRU Assembly','Electro-Mechanical|FRU Assembly','Mechanical|FRU Assembly','Network|FRU Assembly','Vision|FRU Assembly')
					) &gt; 0"/>
	</xsl:template>

	<!-- CO Cover Page Attributes -->
	<xsl:template match="agile:CoverPage">
		<xsl:element name="ChangeOrder">
			<xsl:element name="ChangeOrder_Info">
				<xsl:element name="Change_Number">
					<xsl:value-of select="agile:Number"/>
				</xsl:element>
				<xsl:element name="Description">
					<xsl:value-of select="agile:DescriptionOfChange"/>
				</xsl:element>
				<xsl:element name="Status">
					<xsl:text>Pending</xsl:text>
				</xsl:element>
				<xsl:element name="Type">
					<xsl:value-of select="agile:ChangeType"/>
				</xsl:element>
				<xsl:element name="Planned_Effectivity">
					<xsl:value-of select="../agile:PageTwo/agile:Date02"/>
				</xsl:element>
				<xsl:element name="Status_Date">
					<xsl:value-of select="agile:DateReleased"/>
				</xsl:element>
				<xsl:element name="ChangeOriginator">
					<xsl:value-of select="agile:Originator"/>
				</xsl:element>
			</xsl:element>
			<xsl:apply-templates select="../agile:AffectedItems"/>
			<xsl:if test="(../../agile:Parts/agile:BOM) or (../../agile:Documents/agile:BOM)">
				<xsl:apply-templates select="../agile:AffectedItems/agile:Redlines"/>
			</xsl:if>
		</xsl:element>
	</xsl:template>

	<!-- Affected Items/Material Master Attribute details -->
	<xsl:template match="agile:AffectedItems">
		<xsl:variable name="itemcat">
			<xsl:value-of select="agile:ItemCategory"/>
		</xsl:variable>
		<xsl:variable name="itemtype">
			<xsl:value-of select="agile:ItemType"/>
		</xsl:variable>
		<xsl:variable name="catflag">
			<xsl:choose>
				
				<xsl:when test="($itemcat=('Internal Use Labels|Label Stock','Internal Use Labels|Labels','Product Labeling|Japan Label',
						'Product Labeling|Korea Label','Product Labeling|Labeling KIT','Product Labeling|Labels',
						'Electrical|FRU Assembly','Electro-Mechanical|FRU Assembly','Mechanical|FRU Assembly',
						'Network|FRU Assembly','Vision|FRU Assembly','Device Identifier'))">
					<xsl:value-of select="'true'"/>
				</xsl:when>

				<xsl:when test="agile:Redlines">
						<xsl:call-template name="GLMSCompTemplate"/>
			    </xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'false'"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="$catflag='true'">
				<xsl:element name="MaterialMaster">
					<xsl:element name="Item_Number">
						<xsl:value-of select="agile:ItemNumber"/>
					</xsl:element>
					<xsl:element name="Old_Rev">
						<xsl:value-of select="agile:OldRev"/>
					</xsl:element>
					<xsl:element name="New_Rev">
						<xsl:value-of select="agile:NewRev"/>
					</xsl:element>
					<xsl:element name="Planned_Effectivity_Date">
						<xsl:value-of select="../agile:PageTwo/agile:Date02"/>
					</xsl:element>
					<xsl:element name="Item_Type">
						<xsl:value-of select="agile:ItemType"/>
					</xsl:element>
					<xsl:element name="Material_Type">
						<xsl:value-of select="agile:ItemP2List21"/>
					</xsl:element>
					<xsl:element name="Item_Category">
						<xsl:value-of select="agile:ItemCategory"/>
					</xsl:element>
					<xsl:element name="Description">
						<xsl:value-of select="agile:ItemDescription"/>
					</xsl:element>
					<xsl:element name="Product_Line">
						<xsl:value-of select="agile:ItemProductLines/string()"/>
					</xsl:element>
					<xsl:element name="Lifecycle_Phase">
						<xsl:value-of select="agile:LifecyclePhase"/>
					</xsl:element>
					<!-- Based on the Item Type fetch page two attributes -->
					<xsl:variable name="itemType">
						<xsl:value-of select="agile:ItemType"/>
					</xsl:variable>
					<xsl:variable name="itemnum">
						<xsl:value-of select="agile:ItemNumber"/>
					</xsl:variable>
					<xsl:variable name="rev">
						<xsl:value-of select="agile:NewRev"/>
					</xsl:variable>
					<xsl:variable name="rightparen">(</xsl:variable>
					<xsl:variable name="leftparen">)</xsl:variable>
					<xsl:variable name="coStatus">
						<xsl:value-of select="../agile:CoverPage/agile:Status"/>
					</xsl:variable>
					<xsl:choose>
						<xsl:when test="$itemType='Part'">
							<xsl:if test="$coStatus!='Released'">
								<xsl:apply-templates select="../../agile:Parts">
									<xsl:with-param name="itemnum" select="$itemnum"/>
									<xsl:with-param name="rev" select="concat($rightparen,$rev,$leftparen)"/>
								</xsl:apply-templates>
							</xsl:if>
							<xsl:if test="$coStatus='Released'">
								<xsl:apply-templates select="../../agile:Parts">
									<xsl:with-param name="itemnum" select="$itemnum"/>
									<xsl:with-param name="rev" select="$rev"/>
								</xsl:apply-templates>
							</xsl:if>
						</xsl:when>
						<xsl:otherwise>
							<xsl:if test="$coStatus!='Released'">
								<xsl:apply-templates select="../../agile:Documents">
									<xsl:with-param name="itemnum" select="$itemnum"/>
									<xsl:with-param name="rev" select="concat($rightparen,$rev,$leftparen)"/>
								</xsl:apply-templates>
							</xsl:if>
							<xsl:if test="$coStatus='Released'">
								<xsl:apply-templates select="../../agile:Documents">
									<xsl:with-param name="itemnum" select="$itemnum"/>
									<xsl:with-param name="rev" select="$rev"/>
								</xsl:apply-templates>
							</xsl:if>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:element>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<!-- Fetch Page Two attributes for Parts -->
	<xsl:template match="agile:Parts">
		<xsl:param name="itemnum"/>
		<xsl:param name="rev"/>
		<xsl:if test="(agile:TitleBlock/agile:Number=$itemnum) and (contains(agile:TitleBlock/agile:Rev,$rev))">
			<xsl:element name="Sterilization_Record_Review_At_ISI">
				<xsl:value-of select="agile:PageTwo/agile:List13"/>
			</xsl:element>
			<xsl:element name="GTIN_Information">
				<xsl:value-of select="agile:PageTwo/agile:Multitext31"/>
			</xsl:element>
			<xsl:element name="Latex_Requirements"/>
			<xsl:element name="MRI_Labeling"/>
			<xsl:element name="Brand_Name"/>
			<xsl:element name="Model"/>
			<xsl:element name="Additional_Device_Description"/>
			<xsl:element name="Device_Count"/>
			<xsl:element name="Virtual_DI_Number"/>
			<xsl:element name="Subject_To_Direct_Marking_But_Exempt"/>
			<xsl:element name="Direct_Mark_DI"/>
			<xsl:element name="Single_Use_Device"/>
			<xsl:element name="Resposable_Processing_Requirements"/>
			<xsl:element name="Quantity_per_Package"/>
			<xsl:element name="Packaging_UOM"/>
		</xsl:if>
	</xsl:template>
	
	<!-- Fetch Page Two and Page Three attributes for Documents -->
	<xsl:template match="agile:Documents">
		<xsl:param name="itemnum"/>
		<xsl:param name="rev"/>
		<xsl:if test="(agile:TitleBlock/agile:Number=$itemnum) and (contains(agile:TitleBlock/agile:Rev,$rev))">
			<!-- Page Two -->
			<xsl:element name="Sterilization_Record_Review_At_ISI"/>
			<xsl:element name="GTIN_Information"/>
			<!-- Page Three -->
			<xsl:element name="Latex_Requirements">
				<xsl:value-of select="agile:PageThree/agile:List08"/>
			</xsl:element>
			<xsl:element name="MRI_Labeling">
				<xsl:value-of select="agile:PageThree/agile:List09"/>
			</xsl:element>
			<xsl:element name="Brand_Name">
				<xsl:value-of select="agile:PageThree/agile:Text02"/>
			</xsl:element>
			<xsl:element name="Model">
				<xsl:value-of select="agile:PageThree/agile:Text03"/>
			</xsl:element>
			<xsl:element name="Additional_Device_Description">
				<xsl:value-of select="agile:PageThree/agile:Multitext39"/>
			</xsl:element>
			<xsl:element name="Device_Count">
				<xsl:value-of select="agile:PageThree/agile:Numeric02"/>
			</xsl:element>
			<xsl:element name="Virtual_DI_Number">
				<xsl:value-of select="agile:PageThree/agile:Text05"/>
			</xsl:element>
			<xsl:element name="Subject_To_Direct_Marking_But_Exempt">
				<xsl:value-of select="agile:PageThree/agile:List02"/>
			</xsl:element>
			<xsl:element name="Direct_Mark_DI">
				<xsl:value-of select="agile:PageThree/agile:Text07"/>
			</xsl:element>
			<xsl:element name="Single_Use_Device">
				<xsl:value-of select="agile:PageThree/agile:List07"/>
			</xsl:element>
			<xsl:element name="Resposable_Processing_Requirements">
                <xsl:value-of select="agile:PageThree/agile:FlexAttributes/agile:FlexAttribute[contains(agile:name,'Resposable Processing Requirements')]/agile:value"/>
            </xsl:element>
			<xsl:element name="Quantity_per_Package">
				<xsl:value-of select="agile:PageThree/agile:Numeric01"/>
			</xsl:element>
			<xsl:element name="Packaging_UOM">
				<xsl:value-of select="agile:PageThree/agile:List01"/>
			</xsl:element>
		</xsl:if>
	</xsl:template>

	<!-- Fetch first level BOM Details for items whose Item Category is equal to one of the GLMS identified item categories -->
	<xsl:template match="agile:Redlines">
		<xsl:variable name="itemcat">
			<xsl:value-of select="../agile:ItemCategory"/>
		</xsl:variable>
		<xsl:variable name="itemtype">
			<xsl:value-of select="../agile:ItemType"/>
		</xsl:variable>
		<xsl:variable name="catflag">
			<xsl:choose>
				<xsl:when test="($itemcat=('Internal Use Labels|Label Stock','Internal Use Labels|Labels','Product Labeling|Japan Label',
									'Product Labeling|Korea Label','Product Labeling|Labeling KIT','Product Labeling|Labels',
									'Electrical|FRU Assembly','Electro-Mechanical|FRU Assembly','Mechanical|FRU Assembly','Network|FRU Assembly',
									'Vision|FRU Assembly','Device Identifier'))">
					<xsl:value-of select="'true'"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'false'"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$catflag='true'">
				<xsl:choose>
					<xsl:when test="($itemtype=('Part','Device Identifier')) and (exists(agile:RedlinedBOMRow))">
						<xsl:element name="ParentProduct">
							<xsl:element name="ParentProduct_Info">
								<xsl:element name="BOM_Number">
									<xsl:value-of select="../agile:ItemNumber"/>
								</xsl:element>
								<xsl:element name="Revision_Number">
									<xsl:value-of select="../agile:NewRev"/>
								</xsl:element>
								<xsl:variable name="bomnum">
									<xsl:value-of select="../agile:ItemNumber"/>
								</xsl:variable>
								<xsl:variable name="conum">
									<xsl:value-of select="../../agile:CoverPage/agile:Number"/>
								</xsl:variable>
								<xsl:element name="BOM">
									<xsl:for-each select="agile:RedlinedBOMRow">
										<xsl:call-template name="BOMRedline">
											<xsl:with-param name="bomnum" select="$bomnum"/>
										</xsl:call-template>
									</xsl:for-each>
								</xsl:element>
							</xsl:element>
						</xsl:element>
					</xsl:when>
					<xsl:otherwise>
						<xsl:if test="agile:RedlinedBOMRow">
							<xsl:element name="ParentProduct">
								<xsl:element name="ParentProduct_Info">
									<xsl:element name="BOM_Number">
										<xsl:value-of select="../agile:ItemNumber"/>
									</xsl:element>
									<xsl:element name="Revision_Number">
										<xsl:value-of select="../agile:NewRev"/>
									</xsl:element>
									<xsl:variable name="bomnum">
										<xsl:value-of select="../agile:ItemNumber"/>
									</xsl:variable>
									<xsl:variable name="conum">
										<xsl:value-of select="../../agile:CoverPage/agile:Number"/>
									</xsl:variable>
									<xsl:element name="BOM">
										<xsl:for-each select="agile:RedlinedBOMRow">
											<xsl:call-template name="BOMRedline">
												<xsl:with-param name="bomnum" select="$bomnum"/>
											</xsl:call-template>
										</xsl:for-each>
									</xsl:element>
								</xsl:element>
							</xsl:element>
						</xsl:if>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<!-- Fetch Redline information for each BOM Component -->
	<xsl:template name="BOMRedline">
		<xsl:param name="bomnum"/>
		<!-- Fetch components of BOM whose Item Category is equal to one of the GLMS identified item categories -->
		<xsl:variable name="redlineaction">
			<xsl:value-of select="@RedlineAction"/>
		</xsl:variable>
		<xsl:variable name="curritemcat">
			<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemCategory"/>
		</xsl:variable>
		<xsl:variable name="currprodline">
			<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemProductLines/string()"/>
		</xsl:variable>
		<xsl:variable name="curritemtype">
			<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemType"/>
		</xsl:variable>
		<xsl:variable name="previtemcat">
			<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemCategory"/>
		</xsl:variable>
		<xsl:variable name="prevprodline">
			<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemProductLines/string()"/>
		</xsl:variable>
		<xsl:variable name="previtemtype">
			<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemType"/>
		</xsl:variable>
		<xsl:variable name="itemcat">
			<xsl:choose>
				<!-- For Added, Unchanged action, fetch Current BOM Redline Row -->
				<xsl:when test="$redlineaction =('Added','Unchanged')">
					<xsl:value-of select="$curritemcat"/>
				</xsl:when>
				<!-- For Deleted action, fetch Previous BOM Redline Row -->
				<xsl:when test="$redlineaction='Deleted'">
					<xsl:value-of select="$previtemcat"/>
				</xsl:when>
				<!-- For Changed action, when current item category row is greater than Zero , fetch Current BOM Redline Row -->
				<xsl:when test="($redlineaction='Changed' and string-length($curritemcat) &gt; 0)">
					<xsl:value-of select="$curritemcat"/>
				</xsl:when>
				<!-- For other actions, fetch Previous BOM Redline Row -->
				<xsl:otherwise>
					<xsl:value-of select="$previtemcat"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="prodline">
			<xsl:choose>
				<xsl:when test="$redlineaction =('Added','Unchanged')">
					<xsl:value-of select="$currprodline"/>
				</xsl:when>
				<xsl:when test="$redlineaction='Deleted'">
					<xsl:value-of select="$prevprodline"/>
				</xsl:when>
				<xsl:when test="($redlineaction='Changed' and string-length($currprodline) &gt; 0)">
					<xsl:value-of select="$currprodline"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$prevprodline"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="itemtype">
			<xsl:choose>
				<xsl:when test="$redlineaction =('Added','Unchanged')">
					<xsl:value-of select="$curritemtype"/>
				</xsl:when>
				<xsl:when test="$redlineaction='Deleted'">
					<xsl:value-of select="$previtemtype"/>
				</xsl:when>
				<xsl:when test="($redlineaction='Changed' and string-length($curritemtype) &gt; 0)">
					<xsl:value-of select="$curritemtype"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$previtemtype"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="catflag">
			<xsl:choose>
				<xsl:when test="($itemcat=('Internal Use Labels|Label Stock','Internal Use Labels|Labels','Product Labeling|Japan Label',
									'Product Labeling|Korea Label','Product Labeling|Labeling KIT','Product Labeling|Labels',
									'Electrical|FRU Assembly','Electro-Mechanical|FRU Assembly','Mechanical|FRU Assembly','Network|FRU Assembly',
									'Vision|FRU Assembly','Device Identifier'))">
					<xsl:value-of select="'true'"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'false'"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$catflag='true'">
				<xsl:variable name="currrowitemnum">
					<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemNumber"/>
				</xsl:variable>
				<xsl:variable name="currrowrev">
					<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemRev"/>
				</xsl:variable>
				<xsl:variable name="currrowqty">
					<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:Qty"/>
				</xsl:variable>
				<xsl:variable name="currrowcat">
					<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemCategory"/>
				</xsl:variable>
				<xsl:element name="Component">
					<xsl:element name="Item_Number">
						<xsl:choose>
							<!-- For Added, Unchanged action, fetch Current BOM Redline Row -->
							<xsl:when test="$redlineaction =('Added','Unchanged')">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemNumber"/>
							</xsl:when>
							<!-- For Deleted action, fetch Previous BOM Redline Row -->
							<xsl:when test="$redlineaction='Deleted'">
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemNumber"/>
							</xsl:when>
							<!-- For Changed action, when current item number row is greater than Zero , fetch Current BOM Redline Row -->
							<xsl:when test="($redlineaction='Changed' and string-length($currrowitemnum) &gt; 0)">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemNumber"/>
							</xsl:when>
							<!-- For other actions, fetch Previous BOM Redline Row -->
							<xsl:otherwise>
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemNumber"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
					<xsl:element name="Action">
						<xsl:choose>
							<xsl:when test="$redlineaction='Added'">
								<xsl:value-of select="'A'"/>
							</xsl:when>
							<xsl:when test="$redlineaction='Deleted'">
								<xsl:value-of select="'D'"/>
							</xsl:when>
							<xsl:when test="$redlineaction='Changed'">
								<xsl:value-of select="'U'"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="'NA'"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
					<xsl:element name="Revision_Number">
						<xsl:choose>
							<xsl:when test="$redlineaction =('Added','Unchanged')">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemRev"/>
							</xsl:when>
							<xsl:when test="$redlineaction='Deleted'">
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemRev"/>
							</xsl:when>
							<xsl:when test="($redlineaction='Changed' and string-length($currrowrev) &gt; 0)">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemRev"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemRev"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
					<xsl:element name="Quantity">
						<xsl:choose>
							<xsl:when test="$redlineaction =('Added','Unchanged')">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:Qty"/>
							</xsl:when>
							<xsl:when test="$redlineaction='Deleted'">
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:Qty"/>
							</xsl:when>
							<xsl:when test="($redlineaction='Changed' and string-length($currrowqty) &gt; 0)">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:Qty"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:Qty"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
					<xsl:element name="Category">
						<xsl:choose>
							<xsl:when test="$redlineaction =('Added','Unchanged')">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemCategory"/>
							</xsl:when>
							<xsl:when test="$redlineaction='Deleted'">
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemCategory"/>
							</xsl:when>
							<xsl:when test="($redlineaction='Changed' and string-length($currrowcat) &gt; 0)">
								<xsl:value-of select="current()/agile:RedlinedBOMRowCurrent/agile:ItemCategory"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="current()/agile:RedlinedBOMRowPrevious/agile:ItemCategory"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
				</xsl:element>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2009. Progress Software Corporation. All rights reserved.

<metaInformation>
	<scenarios>
		<scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="agile.xml" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml=""
		          commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator="">
			<advancedProp name="bSchemaAware" value="true"/>
			<advancedProp name="xsltVersion" value="2.0"/>
			<advancedProp name="schemaCache" value="||"/>
			<advancedProp name="iWhitespace" value="0"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="bUseDTD" value="false"/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bTinyTree" value="true"/>
			<advancedProp name="bGenerateByteCode" value="true"/>
			<advancedProp name="bExtensions" value="true"/>
			<advancedProp name="iValidation" value="0"/>
			<advancedProp name="iErrorHandling" value="fatal"/>
			<advancedProp name="sInitialTemplate" value=""/>
			<advancedProp name="sInitialMode" value=""/>
		</scenario>
	</scenarios>
	<MapperMetaTag>
		<MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
		<MapperBlockPosition></MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
-->