Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL translation with if/then statement 1

Status
Not open for further replies.

lassehammer

IS-IT--Management
Joined
May 10, 2004
Messages
9
Location
GB
Hi,

I have included the XML file. I need to pick up the Billing address when no shipping address is shown and the shipping address when it is present.

I have included the xml file.

<?xml version="1.0" encoding="UTF-16"?>
<OrderDoc xmlns:xsd=" xsd:noNamespaceSchemaLocation="CMSOrdersExport.xsd">
<OrderDocHeader>
<Owner>Madsen</Owner>
<CatalogueID>1</CatalogueID>
<FileRef>20040708100008.xml</FileRef>
<CreatedDate>2004-07-08T10:00:08</CreatedDate>
</OrderDocHeader>
<OrdersList>
<Order>
<OrderHeader>
<OrderID>12757</OrderID>
<CatalogueID>1</CatalogueID>
<OrderType>0</OrderType>
<PreAuthDeclinedCount>0</PreAuthDeclinedCount>
<CustomerID>72940</CustomerID>
<TestMode>0</TestMode>
<PreAuthStatus>3</PreAuthStatus>
<OrderStatus>1</OrderStatus>
<ReviewAccepted>false</ReviewAccepted>
<PreAuthAmount>1</PreAuthAmount>
<Description><![CDATA[Order for Mr Mark Madsen. Date/Time:07/07/2004 14:03:20]]></Description>
<CustomerFirstName><![CDATA[Mark]]></CustomerFirstName>
<CustomerLastName><![CDATA[Madsen]]></CustomerLastName>
<CustomerEmail><![CDATA[]]></CustomerEmail>
<CustomerTel><![CDATA[020 7872 9999]]></CustomerTel>
<CustomerMobile><![CDATA[]]></CustomerMobile>
<CustomerWorkTel><![CDATA[]]></CustomerWorkTel>
<CustomerFax><![CDATA[]]></CustomerFax>
<BasketID>47553</BasketID>
<BillingAddressID>4043</BillingAddressID>
<CurrencyID>1</CurrencyID>
<ShippingOptionID>0</ShippingOptionID>
<ShippingAmount>0</ShippingAmount>
<DiscountAmount>0</DiscountAmount>
<BoxCount>0</BoxCount>
<CreatedDate>2004-07-07T14:03:21</CreatedDate>
<PreauthedDate>2004-07-07T14:37:20</PreauthedDate>
<Exported>false</Exported>
</OrderHeader>
<BillingAddress>
<OrderAddressID>4043</OrderAddressID>
<CustomerAddressID>38450</CustomerAddressID>
<FirstName><![CDATA[]]></FirstName>
<LastName><![CDATA[]]></LastName>
<Address1><![CDATA[99 Wrinkley Road]]></Address1>
<Address2><![CDATA[]]></Address2>
<TownCity><![CDATA[Worcester Park]]></TownCity>
<CountyRegion><![CDATA[Suurey]]></CountyRegion>
<PostCode><![CDATA[KT11 8JF]]></PostCode>
<Country>United Kingdom</Country>
<CountryID>1</CountryID>
<LastUpdated>2004-07-07T14:03:21</LastUpdated>
<Created>2004-07-07T14:03:21</Created>
</BillingAddress>
<OrderLines>
<OrderLine>
<OrderLineID>4165</OrderLineID>
<OrderID>12757</OrderID>
<BasketLineID>49681</BasketLineID>
<ProductID>2759</ProductID>
<Quantity>1</Quantity>
<ItemPrice>10.99</ItemPrice>
<ItemSalesTax>0</ItemSalesTax>
<ItemUpgradePrice>0</ItemUpgradePrice>
<ItemUpgradeSalesTax>0</ItemUpgradeSalesTax>
<ProductName><![CDATA[Finding Nemo]]></ProductName>
<PLU><![CDATA[PCX1063]]></PLU>
<LinePointsPending>0</LinePointsPending>
<Awarded>False</Awarded>
<IsPreOrder>False</IsPreOrder>
</OrderLine>
</OrderLines>
<OrderSummary>
<ItemCount>1</ItemCount>
<PriceTotal>10.99</PriceTotal>
<SalesTaxTotal>0</SalesTaxTotal>
<SubTotal>10.99</SubTotal>
<Shipping>0</Shipping>
<PointsRedeemed>0</PointsRedeemed>
<PointsRedemptionValue>0</PointsRedemptionValue>
<GrandTotal>10.99</GrandTotal>
<PointsPendingTotal>0</PointsPendingTotal>
</OrderSummary>
</Order>
<Order>
<OrderHeader>
<OrderID>12758</OrderID>
<CatalogueID>1</CatalogueID>
<OrderType>0</OrderType>
<PreAuthDeclinedCount>0</PreAuthDeclinedCount>
<CustomerID>72941</CustomerID>
<TestMode>0</TestMode>
<PreAuthStatus>3</PreAuthStatus>
<OrderStatus>1</OrderStatus>
<ReviewAccepted>false</ReviewAccepted>
<PreAuthAmount>1</PreAuthAmount>
<Description><![CDATA[SimplyGames Order for MRS Madsen. Date/Time:07/07/2004 15:34:10]]></Description>
<CustomerFirstName><![CDATA[LOUISE]]></CustomerFirstName>
<CustomerLastName><![CDATA[Madsen]]></CustomerLastName>
<CustomerEmail><![CDATA[madsen@ntlworld.com]]></CustomerEmail>
<CustomerTel><![CDATA[]]></CustomerTel>
<CustomerMobile><![CDATA[]]></CustomerMobile>
<CustomerWorkTel><![CDATA[]]></CustomerWorkTel>
<CustomerFax><![CDATA[]]></CustomerFax>
<BasketID>47599</BasketID>
<BillingAddressID>4044</BillingAddressID>
<ShippingAddressID>4045</ShippingAddressID>
<CurrencyID>1</CurrencyID>
<ShippingOptionID>0</ShippingOptionID>
<ShippingAmount>0</ShippingAmount>
<DiscountAmount>0</DiscountAmount>
<BoxCount>0</BoxCount>
<CreatedDate>2004-07-07T15:34:11</CreatedDate>
<PreauthedDate>2004-07-07T15:35:22</PreauthedDate>
<Exported>false</Exported>
</OrderHeader>
<BillingAddress>
<OrderAddressID>4044</OrderAddressID>
<CustomerAddressID>38451</CustomerAddressID>
<FirstName><![CDATA[]]></FirstName>
<LastName><![CDATA[]]></LastName>
<Address1><![CDATA[880 KAMBERLEY ]]></Address1>
<Address2><![CDATA[STONELEIGH]]></Address2>
<TownCity><![CDATA[EPSOM]]></TownCity>
<CountyRegion><![CDATA[SURREY]]></CountyRegion>
<PostCode><![CDATA[KT09 0NG]]></PostCode>
<Country>United Kingdom</Country>
<CountryID>1</CountryID>
<LastUpdated>2004-07-07T15:34:11</LastUpdated>
<Created>2004-07-07T15:34:11</Created>
</BillingAddress>
<ShippingAddress>
<OrderAddressID>4045</OrderAddressID>
<CustomerAddressID>38452</CustomerAddressID>
<FirstName><![CDATA[]]></FirstName>
<LastName><![CDATA[DRAGONS HEALTH CLUB]]></LastName>
<Address1><![CDATA[27 RUXLEY LANE]]></Address1>
<Address2><![CDATA[EWELL]]></Address2>
<TownCity><![CDATA[EPSON]]></TownCity>
<CountyRegion><![CDATA[SURREY]]></CountyRegion>
<PostCode><![CDATA[KT19 0JB]]></PostCode>
<Country>United Kingdom</Country>
<CountryID>1</CountryID>
<LastUpdated>2004-07-07T15:39:11</LastUpdated>
<Created>2004-07-07T15:34:11</Created>
</ShippingAddress>
<OrderLines>
<OrderLine>
<OrderLineID>4166</OrderLineID>
<OrderID>12758</OrderID>
<BasketLineID>49712</BasketLineID>
<ProductID>2945</ProductID>
<Quantity>1</Quantity>
<ItemPrice>76.99</ItemPrice>
<ItemSalesTax>0</ItemSalesTax>
<ItemUpgradePrice>0</ItemUpgradePrice>
<ItemUpgradeSalesTax>0</ItemUpgradeSalesTax>
<ProductName><![CDATA[7.2 Inch Portable Screen For PlayStation 2]]></ProductName>
<PLU><![CDATA[P2P0059]]></PLU>
<LinePointsPending>0</LinePointsPending>
<Awarded>False</Awarded>
<IsPreOrder>False</IsPreOrder>
</OrderLine>
</OrderLines>
<OrderSummary>
<ItemCount>1</ItemCount>
<PriceTotal>76.99</PriceTotal>
<SalesTaxTotal>0</SalesTaxTotal>
<SubTotal>76.99</SubTotal>
<Shipping>0</Shipping>
<PointsRedeemed>0</PointsRedeemed>
<PointsRedemptionValue>0</PointsRedemptionValue>
<GrandTotal>76.99</GrandTotal>
<PointsPendingTotal>0</PointsPendingTotal>
</OrderSummary>
</Order>
</OrdersList>
</OrderDoc>
 
Sorry I overlooked this post.
This it a bit easier, as both addresses seem to have the same structure:
Code:
   <xsl:template match="Order">
      <xsl:value-of select="OrderHeader/Description" />
      <xsl:choose>
         <xsl:when test="ShippingAddress">
            <xsl:call-template name="PrintAddress">
               <xsl:with-param name="address" select="ShippingAddress" />
            </xsl:call-template>
         </xsl:when>
         <xsl:otherwise>
            <xsl:call-template name="PrintAddress">
               <xsl:with-param name="address" select="BillingAddress" />
            </xsl:call-template>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

   <xsl:template name="PrintAddress">
      <xsl:param name="address" />
      <xsl:value-of select="$address/Address1" />
      <xsl:value-of select="$address/Address2" />
   </xsl:template>
 
I presume the code needs to be added to the XSL used to translate the orderfile?

The XSL is as follows:

Code:
<?xml version="1.0" encoding="Windows-1252" ?> 
- <xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:output method="xml" omit-xml-declaration="yes" /> 
- <xsl:template name="PrintAddress">
  <xsl:variable name="date" select="/Rows/Row[Column1 = 'HDR']/Column4" /> 
- <SalesOrders xmlns:sql="urn:schemas-microsoft-com:xml-sql">
- <TransmissionHeader>
  <TransmissionReference>000302</TransmissionReference> 
  <SenderCode>simp</SenderCode> 
  <ReceiverCode>0000000000525</ReceiverCode> 
  <DatePrepared>2004-04-20</DatePrepared> 
  <TimePrepared>23:59</TimePrepared> 
  </TransmissionHeader>
- <Orders>
  <xsl:param name="address" /> 
  <xsl:value-of select="$address/Address1" /> 
  <xsl:value-of select="$address/Address2" /> 
- <xsl:for-each select="OrderDoc/OrdersList/Order">
  <xsl:value-of select="OrderHeader/Description" /> 
- <xsl:choose>
- <xsl:when test="ShippingAddress">
- <xsl:call-template name="PrintAddress">
  <xsl:with-param name="address" select="ShippingAddress" /> 
  </xsl:call-template>
  </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="PrintAddress">
  <xsl:with-param name="address" select="BillingAddress" /> 
  </xsl:call-template>
  </xsl:otherwise>
  </xsl:choose>
- <OrderHeader>
- <CustomerPoNumber>
  <xsl:value-of select="OrderHeader/OrderID" /> 
  </CustomerPoNumber>
  <Customer>SIMP</Customer> 
- <OrderDate>
  <xsl:value-of select="substring(OrderHeader/PreauthedDate,1,10)" /> 
  </OrderDate>
  <OrderActionType>A</OrderActionType> 
  <ShippingInstrs /> 
- <CustomerName>
  <xsl:value-of select="OrderHeader/CustomerFirstName" /> 
  - 
  <xsl:value-of select="OrderHeader/CustomerLastName" /> 
  </CustomerName>
- <ShipAddress1>
  <xsl:value-of select="BillingAddress/Address1" /> 
  </ShipAddress1>
- <ShipAddress2>
  <xsl:value-of select="BillingAddress/Address2" /> 
  </ShipAddress2>
- <ShipAddress3>
  <xsl:value-of select="BillingAddress/TownCity" /> 
  </ShipAddress3>
- <ShipAddress4>
  <xsl:value-of select="BillingAddress/CountyRegion" /> 
  </ShipAddress4>
- <ShipPostalCode>
  <xsl:value-of select="BillingAddress/PostCode" /> 
  </ShipPostalCode>
- <Email>
  <xsl:value-of select="OrderHeader/CustomerEmail" /> 
  </Email>
  <Warehouse>E</Warehouse> 
  <SpecialInstrs /> 
- <RequestedShipDate>
  <xsl:value-of select="substring(OrderHeader/PreauthedDate,1,10)" /> 
  </RequestedShipDate>
  </OrderHeader>
- <OrderDetails>
- <StockLine>
  <CustomerPOLine>1</CustomerPOLine> 
  <LineActionType>A</LineActionType> 
- <StockCode>
  <xsl:value-of select="substring(OrderLines/OrderLine/PLU,1,7)" /> 
  </StockCode>
  <CustomersPartNumber /> 
  <Warehouse>E</Warehouse> 
- <OrderQty>
  <xsl:value-of select="OrderLines/OrderLine/Quantity" /> 
  </OrderQty>
- <Price>
  <xsl:value-of select="format-number(OrderLines/OrderLine/ItemPrice div 1.175,'#,#####0.00000')" /> 
  </Price>
  <PriceUom>EA</PriceUom> 
  <OrderUom>EA</OrderUom> 
  </StockLine>
  </OrderDetails>
  </xsl:for-each>
  </Orders>
  </SalesOrders>
  </xsl:template>
  </xsl:stylesheet>


Where does the code for the address change go?

Sorry for my ignorance! And thanks for your brilliant help so far.

LasseHammer
 
Uh... maybe you'd better post what the result is supposed to be like. You seem to be trying to create a new xml-document, but it doesn't make sense to me.
 
Sorry Jel, let me try and explain.

We receive an order file in XML format. This order file has got both a billing address and shipping address. This file gets translated using an XSL into the right format for our backoffice system. What i am trying to do is to automate the import, so the shipping address gets picked up IF it is present.

I have attached an order file in XML format and the XSL used for the translation.

Is it possible you could look at this and tell me where (if thats the answer) in the XSL i can add the xml code you wrote.


Code:
[b]XML Order[/b]

  <?xml version="1.0" encoding="UTF-16" ?> 
- <OrderDoc xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xsd:noNamespaceSchemaLocation="CMSOrdersExport.xsd">
- <OrderDocHeader>
  <Owner>LasseHammer</Owner> 
  <CatalogueID>1</CatalogueID> 
  <FileRef>20040709100008.xml</FileRef> 
  <CreatedDate>2004-07-09T10:00:08</CreatedDate> 
  </OrderDocHeader>
- <OrdersList>
- <Order>
- <OrderHeader>
  <OrderID>12789</OrderID> 
  <CatalogueID>1</CatalogueID> 
  <OrderType>0</OrderType> 
  <PreAuthDeclinedCount>0</PreAuthDeclinedCount> 
  <CustomerID>72962</CustomerID> 
  <TestMode>0</TestMode> 
  <PreAuthStatus>3</PreAuthStatus> 
  <OrderStatus>1</OrderStatus> 
  <ReviewAccepted>false</ReviewAccepted> 
  <PreAuthAmount>1</PreAuthAmount> 
- <Description>
- <![CDATA[ Order for Lasse Hammer. Date/Time:08/07/2004 14:09:27
  ]]> 
  </Description>
- <CustomerFirstName>
- <![CDATA[ Lasse
  ]]> 
  </CustomerFirstName>
- <CustomerLastName>
- <![CDATA[ Hammer
  ]]> 
  </CustomerLastName>
- <CustomerEmail>
- <![CDATA[ lassehammerdk@hotmail.com
  ]]> 
  </CustomerEmail>
- <CustomerTel>
- <![CDATA[ 01234 567890
  ]]> 
  </CustomerTel>
- <CustomerMobile>
- <![CDATA[ 
  ]]> 
  </CustomerMobile>
- <CustomerWorkTel>
- <![CDATA[ 
  ]]> 
  </CustomerWorkTel>
- <CustomerFax>
- <![CDATA[ 
  ]]> 
  </CustomerFax>
  <BasketID>48469</BasketID> 
  <BillingAddressID>4079</BillingAddressID> 
  <CurrencyID>1</CurrencyID> 
  <ShippingOptionID>0</ShippingOptionID> 
  <ShippingAmount>0</ShippingAmount> 
  <DiscountAmount>0</DiscountAmount> 
  <BoxCount>0</BoxCount> 
  <CreatedDate>2004-07-08T14:09:28</CreatedDate> 
  <PreauthedDate>2004-07-08T14:29:17</PreauthedDate> 
  <Exported>false</Exported> 
  </OrderHeader>
- <BillingAddress>
  <OrderAddressID>4079</OrderAddressID> 
  <CustomerAddressID>38476</CustomerAddressID> 
- <FirstName>
- <![CDATA[ 
  ]]> 
  </FirstName>
- <LastName>
- <![CDATA[ 
  ]]> 
  </LastName>
- <Address1>
- <![CDATA[ 22, Skidgins Road
  ]]> 
  </Address1>
- <Address2>
- <![CDATA[ 
  ]]> 
  </Address2>
- <TownCity>
- <![CDATA[ Clacton-on-Sea
  ]]> 
  </TownCity>
- <CountyRegion>
- <![CDATA[ Essex
  ]]> 
  </CountyRegion>
- <PostCode>
- <![CDATA[ CO12 4RE
  ]]> 
  </PostCode>
  <Country>United Kingdom</Country> 
  <CountryID>1</CountryID> 
  <LastUpdated>2004-07-08T14:09:28</LastUpdated> 
  <Created>2004-07-08T14:09:28</Created> 
  </BillingAddress>
- <OrderLines>
- <OrderLine>
  <OrderLineID>4203</OrderLineID> 
  <OrderID>12789</OrderID> 
  <BasketLineID>50455</BasketLineID> 
  <ProductID>2641</ProductID> 
  <Quantity>1</Quantity> 
  <ItemPrice>9.99</ItemPrice> 
  <ItemSalesTax>0</ItemSalesTax> 
  <ItemUpgradePrice>0</ItemUpgradePrice> 
  <ItemUpgradeSalesTax>0</ItemUpgradeSalesTax> 
- <ProductName>
- <![CDATA[ Wave Race: Blue Storm
  ]]> 
  </ProductName>
- <PLU>
- <![CDATA[ CUX0003
  ]]> 
  </PLU>
  <LinePointsPending>0</LinePointsPending> 
  <Awarded>False</Awarded> 
  <IsPreOrder>False</IsPreOrder> 
  </OrderLine>
  </OrderLines>
- <OrderSummary>
  <ItemCount>1</ItemCount> 
  <PriceTotal>9.99</PriceTotal> 
  <SalesTaxTotal>0</SalesTaxTotal> 
  <SubTotal>9.99</SubTotal> 
  <Shipping>0</Shipping> 
  <PointsRedeemed>0</PointsRedeemed> 
  <PointsRedemptionValue>0</PointsRedemptionValue> 
  <GrandTotal>9.99</GrandTotal> 
  <PointsPendingTotal>0</PointsPendingTotal> 
  </OrderSummary>
  </Order>
- <Order>
- <OrderHeader>
  <OrderID>12790</OrderID> 
  <CatalogueID>1</CatalogueID> 
  <OrderType>0</OrderType> 
  <PreAuthDeclinedCount>0</PreAuthDeclinedCount> 
  <CustomerID>72963</CustomerID> 
  <TestMode>0</TestMode> 
  <PreAuthStatus>3</PreAuthStatus> 
  <OrderStatus>1</OrderStatus> 
  <ReviewAccepted>false</ReviewAccepted> 
  <PreAuthAmount>1</PreAuthAmount> 
- <Description>
- <![CDATA[ Order for mrs Margaret Duval. Date/Time:08/07/2004 14:16:14
  ]]> 
  </Description>
- <CustomerFirstName>
- <![CDATA[ Margaret
  ]]> 
  </CustomerFirstName>
- <CustomerLastName>
- <![CDATA[ Duval
  ]]> 
  </CustomerLastName>
- <CustomerEmail>
- <![CDATA[ eric2den@msn.com
  ]]> 
  </CustomerEmail>
- <CustomerTel>
- <![CDATA[ 01234 567890
  ]]> 
  </CustomerTel>
- <CustomerMobile>
- <![CDATA[ 01234 567890
  ]]> 
  </CustomerMobile>
- <CustomerWorkTel>
- <![CDATA[ 
  ]]> 
  </CustomerWorkTel>
- <CustomerFax>
- <![CDATA[ 
  ]]> 
  </CustomerFax>
- <CustomerNotes>
- <![CDATA[ present for son
  ]]> 
  </CustomerNotes>
  <BasketID>48472</BasketID> 
  <BillingAddressID>4080</BillingAddressID> 
  <ShippingAddressID>4081</ShippingAddressID> 
  <CurrencyID>1</CurrencyID> 
  <ShippingOptionID>0</ShippingOptionID> 
  <ShippingAmount>0</ShippingAmount> 
  <DiscountAmount>0</DiscountAmount> 
  <BoxCount>0</BoxCount> 
  <CreatedDate>2004-07-08T14:16:15</CreatedDate> 
  <PreauthedDate>2004-07-08T16:58:29</PreauthedDate> 
  <Exported>false</Exported> 
  </OrderHeader>
- <BillingAddress>
  <OrderAddressID>4080</OrderAddressID> 
  <CustomerAddressID>38477</CustomerAddressID> 
- <FirstName>
- <![CDATA[ 
  ]]> 
  </FirstName>
- <LastName>
- <![CDATA[ 
  ]]> 
  </LastName>
- <Address1>
- <![CDATA[ 1 Jubilee Road
  ]]> 
  </Address1>
- <Address2>
- <![CDATA[ 
  ]]> 
  </Address2>
- <TownCity>
- <![CDATA[ london
  ]]> 
  </TownCity>
- <CountyRegion>
- <![CDATA[ 
  ]]> 
  </CountyRegion>
- <PostCode>
- <![CDATA[ N17 5RT  ]]> 
  </PostCode>
  <Country>United Kingdom</Country> 
  <CountryID>1</CountryID> 
  <LastUpdated>2004-07-08T14:16:15</LastUpdated> 
  <Created>2004-07-08T14:16:15</Created> 
  </BillingAddress>
- <ShippingAddress>
  <OrderAddressID>4081</OrderAddressID> 
  <CustomerAddressID>38478</CustomerAddressID> 
- <FirstName>
- <![CDATA[ Milla
  ]]> 
  </FirstName>
- <LastName>
- <![CDATA[ Duval
  ]]> 
  </LastName>
- <Address1>
- <![CDATA[ 12 Top ROad
  ]]> 
  </Address1>
- <Address2>
- <![CDATA[ 
  ]]> 
  </Address2>
- <TownCity>
- <![CDATA[ LONDON
  ]]> 
  </TownCity>
- <CountyRegion>
- <![CDATA[ 
  ]]> 
  </CountyRegion>
- <PostCode>
- <![CDATA[ N6 5RT
  ]]> 
  </PostCode>
  <Country>United Kingdom</Country> 
  <CountryID>1</CountryID> 
  <LastUpdated>2004-07-08T14:16:15</LastUpdated> 
  <Created>2004-07-08T14:16:15</Created> 
  </ShippingAddress>
- <OrderLines>
- <OrderLine>
  <OrderLineID>4204</OrderLineID> 
  <OrderID>12790</OrderID> 
  <BasketLineID>50458</BasketLineID> 
  <ProductID>3287</ProductID> 
  <Quantity>1</Quantity> 
  <ItemPrice>159.97</ItemPrice> 
  <ItemSalesTax>0</ItemSalesTax> 
  <ItemUpgradePrice>0</ItemUpgradePrice> 
  <ItemUpgradeSalesTax>0</ItemUpgradeSalesTax> 
- <ProductName>
- <![CDATA[ Xbox: 3 Game Bundle
  ]]> 
  </ProductName>
- <PLU>
- <![CDATA[ XBK0189
  ]]> 
  </PLU>
  <LinePointsPending>0</LinePointsPending> 
  <Awarded>False</Awarded> 
  <IsPreOrder>False</IsPreOrder> 
  </OrderLine>
  </OrderLines>
- <OrderSummary>
  <ItemCount>1</ItemCount> 
  <PriceTotal>159.97</PriceTotal> 
  <SalesTaxTotal>0</SalesTaxTotal> 
  <SubTotal>159.97</SubTotal> 
  <Shipping>0</Shipping> 
  <PointsRedeemed>0</PointsRedeemed> 
  <PointsRedemptionValue>0</PointsRedemptionValue> 
  <GrandTotal>159.97</GrandTotal> 
  <PointsPendingTotal>0</PointsPendingTotal> 
  </OrderSummary>
  </Order>


[b]XSL Translation Sheet[/b]

  <?xml version="1.0" encoding="Windows-1252" ?> 
- <xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:output method="xml" omit-xml-declaration="yes" /> 
- <xsl:template match="/">
  <xsl:variable name="date" select="/Rows/Row[Column1 = 'HDR']/Column4" /> 
- <SalesOrders xmlns:sql="urn:schemas-microsoft-com:xml-sql">
- <TransmissionHeader>
  <TransmissionReference>000302</TransmissionReference> 
  <SenderCode>simp</SenderCode> 
  <ReceiverCode>0000000000525</ReceiverCode> 
  <DatePrepared>2004-04-20</DatePrepared> 
  <TimePrepared>23:59</TimePrepared> 
  </TransmissionHeader>
- <Orders>
- <xsl:for-each select="OrderDoc/OrdersList/Order">
- <OrderHeader>
- <CustomerPoNumber>
  <xsl:value-of select="OrderHeader/OrderID" /> 
  </CustomerPoNumber>
  <Customer>SIMP</Customer> 
- <OrderDate>
  <xsl:value-of select="substring(OrderHeader/PreauthedDate,1,10)" /> 
  </OrderDate>
  <OrderActionType>A</OrderActionType> 
  <ShippingInstrs /> 
- <CustomerName>
  <xsl:value-of select="OrderHeader/CustomerFirstName" /> 
  - 
  <xsl:value-of select="OrderHeader/CustomerLastName" /> 
  </CustomerName>
- <ShipAddress1>
  <xsl:value-of select="BillingAddress/Address1" /> 
  </ShipAddress1>
- <ShipAddress2>
  <xsl:value-of select="BillingAddress/Address2" /> 
  </ShipAddress2>
- <ShipAddress3>
  <xsl:value-of select="BillingAddress/TownCity" /> 
  </ShipAddress3>
- <ShipAddress4>
  <xsl:value-of select="BillingAddress/CountyRegion" /> 
  </ShipAddress4>
- <ShipPostalCode>
  <xsl:value-of select="BillingAddress/PostCode" /> 
  </ShipPostalCode>
- <Email>
  <xsl:value-of select="OrderHeader/CustomerEmail" /> 
  </Email>
  <Warehouse>E</Warehouse> 
  <SpecialInstrs /> 
- <RequestedShipDate>
  <xsl:value-of select="substring(OrderHeader/PreauthedDate,1,10)" /> 
  </RequestedShipDate>
  </OrderHeader>
- <OrderDetails>
- <StockLine>
  <CustomerPOLine>1</CustomerPOLine> 
  <LineActionType>A</LineActionType> 
- <StockCode>
  <xsl:value-of select="substring(OrderLines/OrderLine/PLU,1,7)" /> 
  </StockCode>
  <CustomersPartNumber /> 
  <Warehouse>E</Warehouse> 
- <OrderQty>
  <xsl:value-of select="OrderLines/OrderLine/Quantity" /> 
  </OrderQty>
- <Price>
  <xsl:value-of select="format-number(OrderLines/OrderLine/ItemPrice div 1.175,'#,#####0.00000')" /> 
  </Price>
  <PriceUom>EA</PriceUom> 
  <OrderUom>EA</OrderUom> 
  </StockLine>
  </OrderDetails>
  </xsl:for-each>
  </Orders>
  </SalesOrders>
  </xsl:template>
  </xsl:stylesheet>
 
Is this what you mean?
Code:
<?xml version="1.0"  encoding="Windows-1252" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
   <xsl:output method="xml" omit-xml-declaration="yes" />
   <xsl:template match="/">
      <xsl:variable name="date" select="/Rows/Row[Column1 = 'HDR']/Column4" />
      <SalesOrders xmlns:sql="urn:schemas-microsoft-com:xml-sql">
         <TransmissionHeader>
            <TransmissionReference>000302</TransmissionReference>
            <SenderCode>simp</SenderCode>
            <ReceiverCode>0000000000525</ReceiverCode>
            <DatePrepared>2004-04-20</DatePrepared>
            <TimePrepared>23:59</TimePrepared>
         </TransmissionHeader>
         <Orders>
            <xsl:for-each select="OrderDoc/OrdersList/Order">
               <OrderHeader>
                  <CustomerPoNumber>
                     <xsl:value-of select="OrderHeader/OrderID" />
                  </CustomerPoNumber>
                  <Customer>SIMP</Customer>
                  <OrderDate>
                     <xsl:value-of select="substring(OrderHeader/PreauthedDate,1,10)" />
                  </OrderDate>
                  <OrderActionType>A</OrderActionType>
                  <ShippingInstrs />
                  <CustomerName>
                     <xsl:value-of select="OrderHeader/CustomerFirstName" />
                     <xsl:value-of select="OrderHeader/CustomerLastName" />
                  </CustomerName>

                  <xsl:choose>
                     <xsl:when test="ShippingAddress">
                        <xsl:call-template name="ParseAddress">
                           <xsl:with-param name="address" select="ShippingAddress" />
                        </xsl:call-template>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:call-template name="ParseAddress">
                           <xsl:with-param name="address" select="BillingAddress" />
                        </xsl:call-template>
                     </xsl:otherwise>
                  </xsl:choose>

                  <Email>
                     <xsl:value-of select="OrderHeader/CustomerEmail" />
                  </Email>
                  <Warehouse>E</Warehouse>
                  <SpecialInstrs />
                  <RequestedShipDate>
                     <xsl:value-of select="substring(OrderHeader/PreauthedDate,1,10)" />
                  </RequestedShipDate>
               </OrderHeader>
               <OrderDetails>
                  <StockLine>
                     <CustomerPOLine>1</CustomerPOLine>
                     <LineActionType>A</LineActionType>
                     <StockCode>
                        <xsl:value-of select="substring(OrderLines/OrderLine/PLU,1,7)" />
                     </StockCode>
                     <CustomersPartNumber />
                     <Warehouse>E</Warehouse>
                     <OrderQty>
                        <xsl:value-of select="OrderLines/OrderLine/Quantity" />
                     </OrderQty>
                     <Price>
                        <xsl:value-of select="format-number(OrderLines/OrderLine/ItemPrice div 1.175,'#,#####0.00000')" />
                     </Price>
                     <PriceUom>EA</PriceUom>
                     <OrderUom>EA</OrderUom>
                  </StockLine>
               </OrderDetails>
            </xsl:for-each>
         </Orders>
      </SalesOrders>
   </xsl:template>

   <xsl:template name="ParseAddress">
      <xsl:param name="address" />
      <ShipAddress1>
         <xsl:value-of select="$address/Address1" />
      </ShipAddress1>
      <ShipAddress2>
         <xsl:value-of select="$address/Address2" />
      </ShipAddress2>
      <ShipAddress3>
         <xsl:value-of select="$address/TownCity" />
      </ShipAddress3>
      <ShipAddress4>
         <xsl:value-of select="$address/CountyRegion" />
      </ShipAddress4>
      <ShipPostalCode>
         <xsl:value-of select="$address/PostCode" />
      </ShipPostalCode>
   </xsl:template>
</xsl:stylesheet>
 
Jel,

Thats it. It works perfectly!

Thanks for all your help, very much appreciated!

Regards,

Lasse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top