<?xml version="1.0"?>
<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:param name="base" select="'file:///C:/eStorefrontIn/'"/>

	<xsl:template match="/">
		<xsl:for-each select="root/Order">
			<xsl:result-document  indent="yes" href="{concat($base,  fn:replace(string(current-dateTime()), ':', '-'), '_',  position(), '.xml')}">
				<esb:Envelope xmlns:esb="http://www.ferguson.com/esb">
					<esb:Header>
						<esb:PartyInfo>
							<esb:PartyId type="EC_PARTNER">ENDRIES</esb:PartyId>
							<esb:PartyRole>originator</esb:PartyRole>
						</esb:PartyInfo>
						<esb:Timestamp>2009-02-13T11:57:37Z</esb:Timestamp>
						<esb:TimeToLive>2009-02-13T11:57:37Z</esb:TimeToLive>
					</esb:Header>
					<esb:Body>
						<a:ProcessPurchaseOrder xmlns:a="http://www.openapplications.org/oagis/9" releaseID="1.0">
							<a:ApplicationArea>
								<a:CreationDateTime>
									<xsl:value-of select="EnterDT"/>
								</a:CreationDateTime>
							</a:ApplicationArea>
							<a:DataArea>
								<a:Process/>
								<a:PurchaseOrder>
									<a:PurchaseOrderHeader>
										<a:DocumentID>
											<a:ID>
												<xsl:value-of select="Orderno"/>
											</a:ID>
										</a:DocumentID>
										<a:SupplierParty>
											<a:Name>
												<xsl:value-of select="DataArea"/>
											</a:Name>
										</a:SupplierParty>
										<a:ShipToParty>
											<a:Location>
												<a:ID>
													<xsl:value-of select="Customer"/>
												</a:ID>
												<a:Name>
													<xsl:value-of select="Name"/>
												</a:Name>
												<a:Address>
													<a:AddressLine sequence="{seq1}">
														<xsl:value-of select="Address"/>
													</a:AddressLine>
													<a:AddressLine sequence="{Seq2}">
														<xsl:value-of select="Address2"/>
													</a:AddressLine>
													<a:CityName>
														<xsl:value-of select="City"/>
													</a:CityName>
													<a:CountrySubDivisionCode>
														<xsl:value-of select="State"/>
													</a:CountrySubDivisionCode>
													<a:CountryCode>
														<xsl:value-of select="Country"/>
													</a:CountryCode>
													<a:PostalCode>
														<xsl:value-of select="Zip"/>
													</a:PostalCode>
												</a:Address>
											</a:Location>
										</a:ShipToParty>
										<a:RequestedShipDateTime>
											<xsl:value-of select="ReqDate"/>
										</a:RequestedShipDateTime>
									</a:PurchaseOrderHeader>

									<xsl:for-each select="field/component">
										<a:PurchaseOrderLine>
											<a:LineNumber>
												<xsl:value-of select="po"/>
											</a:LineNumber>
											<xsl:if test="contact">
												<a:Note>
													<xsl:value-of select="contact"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="prodnote1">
												<a:Note>
													<xsl:value-of select="prodnote1"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="prodnote2">
												<a:Note>
													<xsl:value-of select="prodnote2"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="email">
												<a:Note>
													<xsl:value-of select="email"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note1">
												<a:Note>
													<xsl:value-of select="v-note1"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note2">
												<a:Note>
													<xsl:value-of select="v-note2"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note3">
												<a:Note>
													<xsl:value-of select="v-note3"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note4">
												<a:Note>
													<xsl:value-of select="v-note4"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note5">
												<a:Note>
													<xsl:value-of select="v-note5"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note6">
												<a:Note>
													<xsl:value-of select="v-note6"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note7">
												<a:Note>
													<xsl:value-of select="v-note7"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note8">
												<a:Note>
													<xsl:value-of select="v-note8"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note9">
												<a:Note>
													<xsl:value-of select="v-note9"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note10">
												<a:Note>
													<xsl:value-of select="v-note10"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note11">
												<a:Note>
													<xsl:value-of select="v-note11"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note12">
												<a:Note>
													<xsl:value-of select="v-note12"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note13">
												<a:Note>
													<xsl:value-of select="v-note13"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note14">
												<a:Note>
													<xsl:value-of select="v-note14"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note15">
												<a:Note>
													<xsl:value-of select="v-note15"/>
												</a:Note>
											</xsl:if>
											<xsl:if test="v-note16">
												<a:Note>
													<xsl:value-of select="v-note16"/>
												</a:Note>
											</xsl:if>

											<a:Item>
												<a:CustomerItemID>
													<a:ID>
														<xsl:value-of select="item"/>
													</a:ID>
												</a:CustomerItemID>
												<a:Description>
													<xsl:value-of select="des1"/>
												</a:Description>
											</a:Item>
											<a:Quantity>
												<xsl:value-of select="qty"/>
											</a:Quantity>
											<a:UnitPrice>
												<a:Amount currencyID="USD">
													<xsl:value-of select="price"/>
												</a:Amount>
												<a:PerQuantity>
													<xsl:value-of select="perqty"/>
												</a:PerQuantity>
												<a:Code>
													<xsl:value-of select="subcomponent"/>
												</a:Code>
											</a:UnitPrice>
											<a:RequiredDeliveryDateTime>
												<xsl:value-of select="reqdate"/>
											</a:RequiredDeliveryDateTime>
											<a:Distribution>
												<a:EnterpriseUnit>
													<a:GLEntityID>
														<xsl:value-of select="adn"/>
													</a:GLEntityID>
												</a:EnterpriseUnit>
												<a:ProjectReference>
													<a:Description>
														<xsl:value-of select="des1"/>
													</a:Description>
												</a:ProjectReference>
											</a:Distribution>
											<a:RequisitionReference>
												<a:DocumentID>
													<a:ID>
														<xsl:value-of select="po_line"/>
													</a:ID>
												</a:DocumentID>
											</a:RequisitionReference>
										</a:PurchaseOrderLine>
									</xsl:for-each>
								</a:PurchaseOrder>
							</a:DataArea>
						</a:ProcessPurchaseOrder>
					</esb:Body>
				</esb:Envelope>
			</xsl:result-document>
		</xsl:for-each>
	</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="converter:./storefront_send.conv?zzedi856_o.dat" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth=""
		          profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal"
		          customvalidator="">
			<parameterValue name="base" value="'file:///C:/eStorefrontIn/'"/>
			<advancedProp name="sInitialMode" value=""/>
			<advancedProp name="bSchemaAware" value="false"/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="bGenerateByteCode" value="true"/>
			<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="bUseDTD" value="false"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="xsltVersion" value="2.0"/>
			<advancedProp name="iErrorHandling" value="0"/>
		</scenario>
	</scenarios>
	<MapperMetaTag>
		<MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no">
			<SourceSchema srcSchemaPath="converter:./storefront_send.conv?zzedi856_o.dat" srcSchemaRoot="root" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/>
		</MapperInfo>
		<MapperBlockPosition>
			<template match="/"></template>
		</MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
-->