<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://sap.com/xi/AIN">
	<xsl:template match="/">
		<a:PedigreeNotification>
			
			<PedDocumentInfo>
				<PedSerialNumber>
					<xsl:value-of select="a:DespatchedDeliveryNotification/MessageHeader/CreationDateTime"/>
				</PedSerialNumber>
				<PedEnvelope>
					<PedShippedSerialNumber>
						<xsl:value-of select="a:DespatchedDeliveryNotification/MessageHeader/ID"/>
					</PedShippedSerialNumber>
					<PedShippedDate>
						<xsl:value-of select="a:DespatchedDeliveryNotification/MessageHeader/CreationDateTime"/>
					</PedShippedDate>
				</PedEnvelope>
			</PedDocumentInfo>


			<PedInitialPedigree>
					<xsl:for-each select="a:DespatchedDeliveryNotification/Delivery/HandlingUnit">
					<PedContainerInfo>
						<PedContainerSerialNumber>
							<ID>
								<xsl:value-of select="ElectronicLabel/ID"/>
							</ID>
						</PedContainerSerialNumber>
					<xsl:if test="count(Load)!=0">
					<xsl:for-each select="Load">
					<PedProductInfo>
						<PedDrugName>
							<xsl:value-of select="../../Item/Product/InternalID=BusinessTransactionDocumentReference/ItemID"/>
						</PedDrugName>
						<PedManufacturer>
							<xsl:value-of select="../../Item/Product/VendorID"/>
						</PedManufacturer>
						<PedProductCode><xsl:text>SAP PedProductCode</xsl:text>
							<Code>
								<xsl:value-of select="BusinessTransactionDocumentReference/ItemID"/>
							</Code>
						</PedProductCode>
						
						
						<PedItemInfo>
							<PedLot>
								<xsl:value-of select="../Item/Batch/InternalID"/>
							</PedLot>
							<PedExpirationDate>
								<xsl:if test="count(./PedExpirationDate) != 0">
									<xsl:call-template name="FormatDate">
										<xsl:with-param name="Date" select="./PedExpirationDate"/>
									</xsl:call-template>
								</xsl:if>
							</PedExpirationDate>
							<PedQuantity>
								<xsl:value-of select="round(Quantity)"/>
							</PedQuantity>
							<xsl:for-each select="ElectronicLabel">
								<PedItemSerialNumber>
									<ID>
										<xsl:value-of select="ID"/>
									</ID>
								</PedItemSerialNumber>
							</xsl:for-each>
						</PedItemInfo>
					</PedProductInfo>
					</xsl:for-each>
					</xsl:if>
					<xsl:if test="count(LowerLevelHandlingUnit)!=0">
					<PedItemSerialNumber>
					<xsl:for-each select="LowerLevelHandlingUnit">
							
									<ID>
										<xsl:value-of select="ID"/>
									</ID>
							
					</xsl:for-each>
					</PedItemSerialNumber>
					</xsl:if>
					</PedContainerInfo>
					</xsl:for-each>
				
				
				<PedTransactionInfo>
					<PedSenderInfo>
						<PedBusinessAddress>
							<PedBusinessName>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/VendorParty/Address/OrganisationFormattedName"/>
							</PedBusinessName>
							<PedStreet1>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/VendorParty/Address/PhysicalAddress/HouseID"/>
							</PedStreet1>
							<PedStreet2>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/VendorParty/Address/PhysicalAddress/StreetName"/>
							</PedStreet2>
							<PedCity>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/VendorParty/Address/PhysicalAddress/CityName"/>
							</PedCity>
							<PedStateOrRegion>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/VendorParty/Address/PhysicalAddress/RegionCode"/>
							</PedStateOrRegion>
							<PedPostalCode>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/VendorParty/Address/PhysicalAddress/StreetPostalCode"/>
							</PedPostalCode>
							<PedCountry>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/VendorParty/Address/PhysicalAddress/CountryCode"/>
							</PedCountry>
						</PedBusinessAddress>
						<xsl:if test="count(//Delivery/ShipFromLocation/Address) != 0"/>
						<PedShippingAddress>
							<PedBusinessName>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipFromLocation/Address/OrganisationFormattedName"/>
							</PedBusinessName>
							<PedStreet1>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipFromLocation/Address/PhysicalAddress/HouseID"/>
							</PedStreet1>
							<PedStreet2>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipFromLocation/Address/PhysicalAddress/StreetName"/>
							</PedStreet2>
							<PedCity>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipFromLocation/Address/PhysicalAddress/CityName"/>
							</PedCity>
							<PedStateOrRegion>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipFromLocation/Address/PhysicalAddress/RegionCode"/>
							</PedStateOrRegion>
							<PedPostalCode>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipFromLocation/Address/PhysicalAddress/StreetPostalCode"/>
							</PedPostalCode>
							<PedCountry>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipFromLocation/Address/PhysicalAddress/CountryCode"/>
							</PedCountry>
						</PedShippingAddress>
					</PedSenderInfo>
					<PedRecipientInfo>
						<PedBusinessAddress>
							
							<PedBusinessName>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ProductRecipientParty/Address/OrganisationFormattedName"/>
							</PedBusinessName>
							<PedStreet1>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ProductRecipientParty/Address/PhysicalAddress/HouseID"/>
							</PedStreet1>
							<PedStreet2>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ProductRecipientParty/Address/PhysicalAddress/StreetName"/>
							</PedStreet2>
							<PedCity>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ProductRecipientParty/Address/PhysicalAddress/CityName"/>
							</PedCity>
							<PedStateOrRegion>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ProductRecipientParty/Address/PhysicalAddress/RegionCode"/>
							</PedStateOrRegion>
							<PedPostalCode>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ProductRecipientParty/Address/PhysicalAddress/StreetPostalCode"/>
							</PedPostalCode>
							<PedCountry>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ProductRecipientParty/Address/PhysicalAddress/CountryCode"/>
							</PedCountry>
						</PedBusinessAddress>
						<PedShippingAddress>
							
							<PedBusinessName>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipToLocation/Address/OrganisationFormattedName"/>
							</PedBusinessName>
							<PedStreet1>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipToLocation/Address/PhysicalAddress/HouseID"/>
							</PedStreet1>
							<PedStreet2>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipToLocation/Address/PhysicalAddress/StreetName"/>
							</PedStreet2>
							<PedCity>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipToLocation/Address/PhysicalAddress/CityName"/>
							</PedCity>
							<PedStateOrRegion>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipToLocation/Address/PhysicalAddress/RegionCode"/>
							</PedStateOrRegion>
							<PedPostalCode>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipToLocation/Address/PhysicalAddress/StreetPostalCode"/>
							</PedPostalCode>
							<PedCountry>
								<xsl:value-of select="DespatchedDeliveryNotification/Delivery/ShipToLocation/Address/PhysicalAddress/CountryCode"/>
							</PedCountry>
						</PedShippingAddress>
					</PedRecipientInfo>
				</PedTransactionInfo>
			</PedInitialPedigree>
		</a:PedigreeNotification>
	</xsl:template>
	<xsl:template name="FormatDate">
		<xsl:param name="Date">00000101</xsl:param>
		<xsl:value-of select="substring($Date, 1 ,4)"/>-<xsl:value-of select="substring($Date,5,2 )"/>-<xsl:value-of select="substring($Date,7,2 )"/>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="PedigreeInput1.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="sInitialMode" value=""/><advancedProp name="bXsltOneIsOkay" value="true"/><advancedProp name="bSchemaAware" value="true"/><advancedProp name="bXml11" value="false"/><advancedProp name="iValidation" value="0"/><advancedProp name="bExtensions" value="true"/><advancedProp name="iWhitespace" value="0"/><advancedProp name="sInitialTemplate" value=""/><advancedProp name="bTinyTree" value="true"/><advancedProp name="bWarnings" value="true"/><advancedProp name="bUseDTD" value="false"/><advancedProp name="iErrorHandling" value="fatal"/></scenario></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="PedigreeNotification.xsd" destSchemaRoot="PedigreeNotification" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no" ><SourceSchema srcSchemaPath="DespatchedDeliveryNotification.xsd" srcSchemaRoot="DespatchedDeliveryNotification" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/></MapperInfo><MapperBlockPosition><template match="/"><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each" x="368" y="234"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedDrugName/xsl:value-of" x="368" y="151"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedManufacturer/xsl:value-of" x="408" y="151"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedProductCode/Code/xsl:value-of" x="328" y="151"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/PedLot/xsl:value-of" x="288" y="151"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/PedExpirationDate/xsl:if/!=[0]" x="132" y="119"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/PedExpirationDate/xsl:if/!=[0]/count[0]" x="86" y="113"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/PedExpirationDate/xsl:if" x="178" y="121"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/PedExpirationDate/xsl:if/xsl:call-template" x="248" y="151"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/PedQuantity/xsl:value-of" x="128" y="151"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/xsl:for-each" x="88" y="151"/><block path="a:PedigreeNotification/PedInitialPedigree/xsl:for-each/PedContainerInfo/PedProductInfo/PedItemInfo/xsl:for-each/PedItemSerialNumber/ID/xsl:value-of" x="48" y="151"/></template></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="target"><Fragment url="" path="" action=""/></MapperFilter></MapperMetaTag>
</metaInformation>
-->