使用mule中的xslt转换将xml转换为soap请求

时间:2015-03-02 15:09:00

标签: xslt mule transformation esb

如何在mule中使用XSLT将xml转换为soap消息?

我正在使用mule社区添加,因此我无法使用mule datamapper。

任何人都可以帮我解决如何使用XSLT转换将xml转换为soap消息吗?

我有以下xml:

  <file>
  <header>
    <documentType>CEN_ORD</documentType>
    <version>1.0</version>
    <createDate>01/01/15 02:11</createDate>
    <originator>IKEA</originator>
    <timeZone>PST</timeZone>
    <dateFormat>MM/dd/yy HH:mm</dateFormat>
    <currencyFormat>USD</currencyFormat>
    <weightUnits>lbs</weightUnits>
    <linearUnits>meter</linearUnits>
    <priceBuCode>158</priceBuCode>
    <routeBuCode>158</routeBuCode>
    <serviceProviderAbbreviation />
    <serviceProviderId />
    <origin>158STO</origin>
    <destination />
  </header>
  <data>
    <deliveryOrder>
      <deliveryMethod>LCD zone D future</deliveryMethod>
      <excReturn>FALSE</excReturn>
      <operation>Update</operation>
      <deliveryType>HDF</deliveryType>
      <totalArticleQuantity>9</totalArticleQuantity>
      <totalArticlePackages>10</totalArticlePackages>
      <totalArticleWeight>438.9512922</totalArticleWeight>
      <totalArticleVolume>1.0083</totalArticleVolume>
      <sacId />
      <businessUnit>
        <code>158</code>
        <countryCode>US</countryCode>
        <languageCode>SWE</languageCode>
        <name />
        <phone />
        <text />
        <timeZone />
        <daylightSavings />
      </businessUnit>
      <orderCustomer>
        <priceBu>158</priceBu>
        <orderNumber>192963803</orderNumber>
        <type>LCD</type>
        <customerName>Nefail Aljic</customerName>
        <attention />
        <careOfName />
        <addr1>147 Notre Dame Ave, apt #3</addr1>
        <addr2>Hillsborough</addr2>
        <addr3 />
        <city>Manchester</city>
        <state>NH</state>
        <zipCode>03102</zipCode>
        <countryCode>US</countryCode>
        <dayPhone>603 315 4161</dayPhone>
        <eveningPhone />
        <cellPhone />
        <fax />
        <email>nefail74@msn.com</email>
      </orderCustomer>
      <packages>
        <package>
          <packageNumber>100052526030</packageNumber>
          <packageWeight>43.89512922</packageWeight>
          <packageVolume>0.10083</packageVolume>
          <palletNumber />
          <mixedPallet>N/A</mixedPallet>
        </package>
      </packages>
      <order>
        <priceBu>158</priceBu>
        <number>192963803</number>
        <createDate>01/01/15</createDate>
        <shipmentNo>100052526030</shipmentNo>
        <departureNo/>
        <departureDate>12/31/14 20:06</departureDate>
        <status />
        <deliveryDate>01/10/15 08:00</deliveryDate>
        <deliveryDateFrom>01/10/15 08:00</deliveryDateFrom>
        <deliveryDateTo>01/10/15 22:00</deliveryDateTo>
        <cancelDate />
        <createUserId />
        <vehicleId />
      </order>
      <orderLines>
        <orderLine>
          <priceBu>158</priceBu>
          <orderNumber />
          <lineNumber>0</lineNumber>
          <articleNumber>40214551</articleNumber>
          <articleQuantity>0</articleQuantity>
          <originalArticleQuantity>1</originalArticleQuantity>
          <articlePackages />
          <articleReferenceNumber />
          <isOutOfStore />
          <receivedDate />
          <storageLocation />
          <receiptDate />
          <moveVehicleId />
          <moveDate />
          <languageCode />
          <number>40214551</number>
          <description>MALM chst/3drw 31 5/8x30 3/4" white N</description>
          <weight>77.27123</weight>
          <volume>0.0744</volume>
        </orderLine>
      </orderLines>
      <orderComment>
        <priceBu>158</priceBu>
        <orderNumber>192963803</orderNumber>
        <createDate />
        <commentCode>15</commentCode>
        <commentValue>YES</commentValue>
        <commentText>3</commentText>
        <userId />
      </orderComment>
      <orderComment>
        <priceBu>158</priceBu>
        <orderNumber>192963803</orderNumber>
        <createDate />
        <commentCode>15</commentCode>
        <commentValue>YES</commentValue>
        <commentText>3</commentText>
        <userId />
      </orderComment>
    </deliveryOrder>
  </data>
</file>

肥皂请求是

 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ship="url">
   <soap:Header/>
   <soap:Body>
      <ship:SendShipmentProcessRequest>
         <!--Optional:-->
         <ship:ShipmentProcessRequest>
            <!--Optional:-->
            <ship:ShipmentProcess>
               <!--Optional:-->
               <ship:DocumentType>?</ship:DocumentType>
               <!--Optional:-->
               <ship:Version>?</ship:Version>
               <ship:CreateDate>?</ship:CreateDate>
               <!--Optional:-->
               <ship:Originator>?</ship:Originator>
               <!--Optional:-->
               <ship:TimeZone>?</ship:TimeZone>
               <!--Optional:-->
               <ship:DateFormat>?</ship:DateFormat>
               <!--Optional:-->
               <ship:CurrencyFormat>?</ship:CurrencyFormat>
               <!--Optional:-->
               <ship:WeightUnits>?</ship:WeightUnits>
               <!--Optional:-->
               <ship:LinearUnits>?</ship:LinearUnits>
               <!--Optional:-->
               <ship:PriceBuCode>?</ship:PriceBuCode>
               <!--Optional:-->
               <ship:RouteBuCode>?</ship:RouteBuCode>
               <!--Optional:-->
               <ship:ServiceProviderAbbreviation>?</ship:ServiceProviderAbbreviation>
               <!--Optional:-->
               <ship:ServiceProviderId>?</ship:ServiceProviderId>
               <!--Optional:-->
               <ship:Origin>?</ship:Origin>
               <!--Optional:-->
               <ship:Destination>?</ship:Destination>
               <!--Optional:-->
               <ship:DeliveryOrders>
                  <!--Zero or more repetitions:-->
                  <ship:DeliveryOrder>
                     <!--Optional:-->
                     <ship:DeliveryMethod>?</ship:DeliveryMethod>
                     <!--Optional:-->
                     <ship:SACId>?</ship:SACId>
                     <!--Optional:-->
                     <ship:Operation>?</ship:Operation>
                     <!--Optional:-->
                     <ship:DeliveryType>?</ship:DeliveryType>
                     <ship:IsExchange>?</ship:IsExchange>
                     <ship:IsMerge>?</ship:IsMerge>
                     <!--Optional:-->
                     <ship:MergeOrderNumber>?</ship:MergeOrderNumber>
                     <ship:TotalArticleQuantity>?</ship:TotalArticleQuantity>
                     <ship:TotalArticlePackages>?</ship:TotalArticlePackages>
                     <ship:TotalArticleWeight>?</ship:TotalArticleWeight>
                     <ship:TotalArticleVolume>?</ship:TotalArticleVolume>
                     <!--Optional:-->
                     <ship:BusinessUnit>
                        <!--Optional:-->
                        <ship:Code>?</ship:Code>
                        <!--Optional:-->
                        <ship:CountryCode>?</ship:CountryCode>
                        <!--Optional:-->
                        <ship:LanguageCode>?</ship:LanguageCode>
                        <!--Optional:-->
                        <ship:Name>?</ship:Name>
                        <!--Optional:-->
                        <ship:Phone>?</ship:Phone>
                        <!--Optional:-->
                        <ship:Text>?</ship:Text>
                        <!--Optional:-->
                        <ship:TimeZone>?</ship:TimeZone>
                        <ship:DaylightSavings>?</ship:DaylightSavings>
                     </ship:BusinessUnit>
                     <!--Optional:-->
                     <ship:OrderCustomer>
                        <!--Optional:-->
                        <ship:PriceBu>?</ship:PriceBu>
                        <!--Optional:-->
                        <ship:OrderNumber>?</ship:OrderNumber>
                        <!--Optional:-->
                        <ship:Type>?</ship:Type>
                        <!--Optional:-->
                        <ship:CustomerName>?</ship:CustomerName>
                        <!--Optional:-->
                        <ship:Addr1>?</ship:Addr1>
                        <!--Optional:-->
                        <ship:Addr2>?</ship:Addr2>
                        <!--Optional:-->
                        <ship:Addr3>?</ship:Addr3>
                        <!--Optional:-->
                        <ship:City>?</ship:City>
                        <!--Optional:-->
                        <ship:State>?</ship:State>
                        <!--Optional:-->
                        <ship:ZipCode>?</ship:ZipCode>
                        <!--Optional:-->
                        <ship:CountryCode>?</ship:CountryCode>
                        <!--Optional:-->
                        <ship:DayPhone>?</ship:DayPhone>
                        <!--Optional:-->
                        <ship:EveningPhone>?</ship:EveningPhone>
                        <!--Optional:-->
                        <ship:CellPhone>?</ship:CellPhone>
                        <!--Optional:-->
                        <ship:Fax>?</ship:Fax>
                        <!--Optional:-->
                        <ship:Email>?</ship:Email>
                     </ship:OrderCustomer>
                     <!--Optional:-->
                     <ship:OrderSource>
                        <!--Optional:-->
                        <ship:OrderNumber>?</ship:OrderNumber>
                        <!--Optional:-->
                        <ship:Type>?</ship:Type>
                        <!--Optional:-->
                        <ship:FirstName>?</ship:FirstName>
                        <!--Optional:-->
                        <ship:LastName>?</ship:LastName>
                        <!--Optional:-->
                        <ship:Addr1>?</ship:Addr1>
                        <!--Optional:-->
                        <ship:Addr2>?</ship:Addr2>
                        <!--Optional:-->
                        <ship:Addr3>?</ship:Addr3>
                        <!--Optional:-->
                        <ship:City>?</ship:City>
                        <!--Optional:-->
                        <ship:State>?</ship:State>
                        <!--Optional:-->
                        <ship:ZipCode>?</ship:ZipCode>
                        <!--Optional:-->
                        <ship:CountryCode>?</ship:CountryCode>
                        <!--Optional:-->
                        <ship:DayPhone>?</ship:DayPhone>
                        <!--Optional:-->
                        <ship:EveningPhone>?</ship:EveningPhone>
                        <!--Optional:-->
                        <ship:CellPhone>?</ship:CellPhone>
                        <!--Optional:-->
                        <ship:Fax>?</ship:Fax>
                        <!--Optional:-->
                        <ship:Email>?</ship:Email>
                     </ship:OrderSource>
                     <ship:HasPackages>?</ship:HasPackages>
                     <!--Optional:-->
                     <ship:Packages>
                        <!--Zero or more repetitions:-->
                        <ship:Package>
                           <!--Optional:-->
                           <ship:PackageNumber>?</ship:PackageNumber>
                           <ship:PackageWeight>?</ship:PackageWeight>
                           <ship:PackageVolume>?</ship:PackageVolume>
                           <!--Optional:-->
                           <ship:PalletNumber>?</ship:PalletNumber>
                           <!--Optional:-->
                           <ship:MixedPallet>?</ship:MixedPallet>
                        </ship:Package>
                     </ship:Packages>
                     <!--Optional:-->
                     <ship:Order>
                        <!--Optional:-->
                        <ship:PriceBu>?</ship:PriceBu>
                        <!--Optional:-->
                        <ship:Number>?</ship:Number>
                        <!--Optional:-->
                        <ship:IdentifierKey>?</ship:IdentifierKey>
                        <ship:CreateDate>?</ship:CreateDate>
                        <!--Optional:-->
                        <ship:BOLNo>?</ship:BOLNo>
                        <!--Optional:-->
                        <ship:DepartureNo>?</ship:DepartureNo>
                        <ship:DepartureDate>?</ship:DepartureDate>
                        <!--Optional:-->
                        <ship:Status>?</ship:Status>
                        <ship:HasDeliveryDate>?</ship:HasDeliveryDate>
                        <ship:DeliveryDate>?</ship:DeliveryDate>
                        <ship:DeliveryDateFrom>?</ship:DeliveryDateFrom>
                        <ship:DeliveryDateTo>?</ship:DeliveryDateTo>
                        <ship:CancelDate>?</ship:CancelDate>
                        <!--Optional:-->
                        <ship:CreateUserId>?</ship:CreateUserId>
                        <ship:UpdateDate>?</ship:UpdateDate>
                        <!--Optional:-->
                        <ship:UpdateUserId>?</ship:UpdateUserId>
                        <!--Optional:-->
                        <ship:VehicleId>?</ship:VehicleId>
                        <ship:HasOrderLines>?</ship:HasOrderLines>
                        <!--Optional:-->
                        <ship:OrderLines>
                           <!--Zero or more repetitions:-->
                           <ship:OrderLine>
                              <!--Optional:-->
                              <ship:PriceBu>?</ship:PriceBu>
                              <!--Optional:-->
                              <ship:OrderNumber>?</ship:OrderNumber>
                              <ship:LineNumber>?</ship:LineNumber>
                              <!--Optional:-->
                              <ship:ArticleNumber>?</ship:ArticleNumber>
                              <ship:ArticleQuantity>?</ship:ArticleQuantity>
                              <ship:OriginalArticleQuantity>?</ship:OriginalArticleQuantity>
                              <ship:ArticlePackages>?</ship:ArticlePackages>
                              <!--Optional:-->
                              <ship:ArticleReferenceNumber>?</ship:ArticleReferenceNumber>
                              <ship:IsOutOfStore>?</ship:IsOutOfStore>
                              <ship:ReceivedDate>?</ship:ReceivedDate>
                              <!--Optional:-->
                              <ship:StorageLocation>?</ship:StorageLocation>
                              <ship:ReceiptDate>?</ship:ReceiptDate>
                              <!--Optional:-->
                              <ship:MoveVehicleId>?</ship:MoveVehicleId>
                              <ship:MoveDate>?</ship:MoveDate>
                              <!--Optional:-->
                              <ship:Description>?</ship:Description>
                              <ship:Weight>?</ship:Weight>
                              <ship:Volume>?</ship:Volume>
                           </ship:OrderLine>
                        </ship:OrderLines>
                        <ship:HasOrderComments>?</ship:HasOrderComments>
                        <!--Optional:-->
                        <ship:OrderComments>
                           <!--Zero or more repetitions:-->
                           <ship:OrderComment>
                              <!--Optional:-->
                              <ship:PriceBu>?</ship:PriceBu>
                              <!--Optional:-->
                              <ship:OrderNumber>?</ship:OrderNumber>
                              <ship:CreateDate>?</ship:CreateDate>
                              <!--Optional:-->
                              <ship:CommentCode>?</ship:CommentCode>
                              <!--Optional:-->
                              <ship:CommentText>?</ship:CommentText>
                              <!--Optional:-->
                              <ship:UserId>?</ship:UserId>
                           </ship:OrderComment>
                        </ship:OrderComments>
                     </ship:Order>
                     <ship:HasOrderSourceAddress>?</ship:HasOrderSourceAddress>
                     <ship:UseSourceAddressLookup>?</ship:UseSourceAddressLookup>
                     <!--Optional:-->
                     <ship:SourceAddressLookupCode>?</ship:SourceAddressLookupCode>
                  </ship:DeliveryOrder>
               </ship:DeliveryOrders>
            </ship:ShipmentProcess>
         </ship:ShipmentProcessRequest>
      </ship:SendShipmentProcessRequest>
   </soap:Body>
</soap:Envelope>

2 个答案:

答案 0 :(得分:0)

您可以使用以下XSLT映射input.xml的每个元素: -

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">

        <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ship="url">
   <soap:Header/>
   <soap:Body>
      <ship:SendShipmentProcessRequest>
         <!--Optional:-->
         <ship:ShipmentProcessRequest>
            <!--Optional:-->
            <ship:ShipmentProcess>
               <!--Optional:-->
               <xsl:if test="file/header/documentType">
               <ship:DocumentType><xsl:value-of select="file/header/documentType/text()" /></ship:DocumentType>
               </xsl:if>
               <!--Optional:-->
               <xsl:if  test="file/header/version">
               <ship:Version><xsl:value-of select="file/header/version/text()" /></ship:Version>
               </xsl:if>
               <xsl:if  test="file/header/createDate">
               <ship:CreateDate><xsl:value-of select="file/header/createDate/text()" /></ship:CreateDate>
               </xsl:if>
               <!--Optional:-->
               <xsl:if  test="file/header/originator">
               <ship:Originator><xsl:value-of select="file/header/originator/text()" /></ship:Originator>
               </xsl:if>
               <!--Optional:-->
               <ship:TimeZone>?</ship:TimeZone>
               <!--Optional:-->
               <ship:DateFormat>?</ship:DateFormat>
               <!--Optional:-->
               <ship:CurrencyFormat>?</ship:CurrencyFormat>
               <!--Optional:-->
               <ship:WeightUnits>?</ship:WeightUnits>
               <!--Optional:-->
               <ship:LinearUnits>?</ship:LinearUnits>
               <!--Optional:-->
               <ship:PriceBuCode>?</ship:PriceBuCode>
               <!--Optional:-->
               <ship:RouteBuCode>?</ship:RouteBuCode>
               <!--Optional:-->
               <ship:ServiceProviderAbbreviation>?</ship:ServiceProviderAbbreviation>
               <!--Optional:-->
               <ship:ServiceProviderId>?</ship:ServiceProviderId>
               <!--Optional:-->
               <ship:Origin>?</ship:Origin>
               <!--Optional:-->
               <ship:Destination>?</ship:Destination>
               <!--Optional:-->
               <ship:DeliveryOrders>
                  <!--Zero or more repetitions:-->
                  <ship:DeliveryOrder>
                     <!--Optional:-->
                     <ship:DeliveryMethod>?</ship:DeliveryMethod>
                     <!--Optional:-->
                     <ship:SACId>?</ship:SACId>
                     <!--Optional:-->
                     <ship:Operation>?</ship:Operation>
                     <!--Optional:-->
                     <ship:DeliveryType>?</ship:DeliveryType>
                     <ship:IsExchange>?</ship:IsExchange>
                     <ship:IsMerge>?</ship:IsMerge>
                     <!--Optional:-->
                     <ship:MergeOrderNumber>?</ship:MergeOrderNumber>
                     <ship:TotalArticleQuantity>?</ship:TotalArticleQuantity>
                     <ship:TotalArticlePackages>?</ship:TotalArticlePackages>
                     <ship:TotalArticleWeight>?</ship:TotalArticleWeight>
                     <ship:TotalArticleVolume>?</ship:TotalArticleVolume>
                     <!--Optional:-->
                     <ship:BusinessUnit>
                        <!--Optional:-->
                        <ship:Code>?</ship:Code>
                        <!--Optional:-->
                        <ship:CountryCode>?</ship:CountryCode>
                        <!--Optional:-->
                        <ship:LanguageCode>?</ship:LanguageCode>
                        <!--Optional:-->
                        <ship:Name>?</ship:Name>
                        <!--Optional:-->
                        <ship:Phone>?</ship:Phone>
                        <!--Optional:-->
                        <ship:Text>?</ship:Text>
                        <!--Optional:-->
                        <ship:TimeZone>?</ship:TimeZone>
                        <ship:DaylightSavings>?</ship:DaylightSavings>
                     </ship:BusinessUnit>
                     <!--Optional:-->
                     <ship:OrderCustomer>
                        <!--Optional:-->
                        <ship:PriceBu>?</ship:PriceBu>
                        <!--Optional:-->
                        <ship:OrderNumber>?</ship:OrderNumber>
                        <!--Optional:-->
                        <ship:Type>?</ship:Type>
                        <!--Optional:-->
                        <ship:CustomerName>?</ship:CustomerName>
                        <!--Optional:-->
                        <ship:Addr1>?</ship:Addr1>
                        <!--Optional:-->
                        <ship:Addr2>?</ship:Addr2>
                        <!--Optional:-->
                        <ship:Addr3>?</ship:Addr3>
                        <!--Optional:-->
                        <ship:City>?</ship:City>
                        <!--Optional:-->
                        <ship:State>?</ship:State>
                        <!--Optional:-->
                        <ship:ZipCode>?</ship:ZipCode>
                        <!--Optional:-->
                        <ship:CountryCode>?</ship:CountryCode>
                        <!--Optional:-->
                        <ship:DayPhone>?</ship:DayPhone>
                        <!--Optional:-->
                        <ship:EveningPhone>?</ship:EveningPhone>
                        <!--Optional:-->
                        <ship:CellPhone>?</ship:CellPhone>
                        <!--Optional:-->
                        <ship:Fax>?</ship:Fax>
                        <!--Optional:-->
                        <ship:Email>?</ship:Email>
                     </ship:OrderCustomer>
                     <!--Optional:-->
                     <ship:OrderSource>
                        <!--Optional:-->
                        <ship:OrderNumber>?</ship:OrderNumber>
                        <!--Optional:-->
                        <ship:Type>?</ship:Type>
                        <!--Optional:-->
                        <ship:FirstName>?</ship:FirstName>
                        <!--Optional:-->
                        <ship:LastName>?</ship:LastName>
                        <!--Optional:-->
                        <ship:Addr1>?</ship:Addr1>
                        <!--Optional:-->
                        <ship:Addr2>?</ship:Addr2>
                        <!--Optional:-->
                        <ship:Addr3>?</ship:Addr3>
                        <!--Optional:-->
                        <ship:City>?</ship:City>
                        <!--Optional:-->
                        <ship:State>?</ship:State>
                        <!--Optional:-->
                        <ship:ZipCode>?</ship:ZipCode>
                        <!--Optional:-->
                        <ship:CountryCode>?</ship:CountryCode>
                        <!--Optional:-->
                        <ship:DayPhone>?</ship:DayPhone>
                        <!--Optional:-->
                        <ship:EveningPhone>?</ship:EveningPhone>
                        <!--Optional:-->
                        <ship:CellPhone>?</ship:CellPhone>
                        <!--Optional:-->
                        <ship:Fax>?</ship:Fax>
                        <!--Optional:-->
                        <ship:Email>?</ship:Email>
                     </ship:OrderSource>
                     <ship:HasPackages>?</ship:HasPackages>
                     <!--Optional:-->
                     <ship:Packages>
                        <!--Zero or more repetitions:-->
                        <ship:Package>
                           <!--Optional:-->
                           <ship:PackageNumber>?</ship:PackageNumber>
                           <ship:PackageWeight>?</ship:PackageWeight>
                           <ship:PackageVolume>?</ship:PackageVolume>
                           <!--Optional:-->
                           <ship:PalletNumber>?</ship:PalletNumber>
                           <!--Optional:-->
                           <ship:MixedPallet>?</ship:MixedPallet>
                        </ship:Package>
                     </ship:Packages>
                     <!--Optional:-->
                     <ship:Order>
                        <!--Optional:-->
                        <ship:PriceBu>?</ship:PriceBu>
                        <!--Optional:-->
                        <ship:Number>?</ship:Number>
                        <!--Optional:-->
                        <ship:IdentifierKey>?</ship:IdentifierKey>
                        <ship:CreateDate>?</ship:CreateDate>
                        <!--Optional:-->
                        <ship:BOLNo>?</ship:BOLNo>
                        <!--Optional:-->
                        <ship:DepartureNo>?</ship:DepartureNo>
                        <ship:DepartureDate>?</ship:DepartureDate>
                        <!--Optional:-->
                        <ship:Status>?</ship:Status>
                        <ship:HasDeliveryDate>?</ship:HasDeliveryDate>
                        <ship:DeliveryDate>?</ship:DeliveryDate>
                        <ship:DeliveryDateFrom>?</ship:DeliveryDateFrom>
                        <ship:DeliveryDateTo>?</ship:DeliveryDateTo>
                        <ship:CancelDate>?</ship:CancelDate>
                        <!--Optional:-->
                        <ship:CreateUserId>?</ship:CreateUserId>
                        <ship:UpdateDate>?</ship:UpdateDate>
                        <!--Optional:-->
                        <ship:UpdateUserId>?</ship:UpdateUserId>
                        <!--Optional:-->
                        <ship:VehicleId>?</ship:VehicleId>
                        <ship:HasOrderLines>?</ship:HasOrderLines>
                        <!--Optional:-->
                        <ship:OrderLines>
                           <!--Zero or more repetitions:-->
                           <ship:OrderLine>
                              <!--Optional:-->
                              <ship:PriceBu>?</ship:PriceBu>
                              <!--Optional:-->
                              <ship:OrderNumber>?</ship:OrderNumber>
                              <ship:LineNumber>?</ship:LineNumber>
                              <!--Optional:-->
                              <ship:ArticleNumber>?</ship:ArticleNumber>
                              <ship:ArticleQuantity>?</ship:ArticleQuantity>
                              <ship:OriginalArticleQuantity>?</ship:OriginalArticleQuantity>
                              <ship:ArticlePackages>?</ship:ArticlePackages>
                              <!--Optional:-->
                              <ship:ArticleReferenceNumber>?</ship:ArticleReferenceNumber>
                              <ship:IsOutOfStore>?</ship:IsOutOfStore>
                              <ship:ReceivedDate>?</ship:ReceivedDate>
                              <!--Optional:-->
                              <ship:StorageLocation>?</ship:StorageLocation>
                              <ship:ReceiptDate>?</ship:ReceiptDate>
                              <!--Optional:-->
                              <ship:MoveVehicleId>?</ship:MoveVehicleId>
                              <ship:MoveDate>?</ship:MoveDate>
                              <!--Optional:-->
                              <ship:Description>?</ship:Description>
                              <ship:Weight>?</ship:Weight>
                              <ship:Volume>?</ship:Volume>
                           </ship:OrderLine>
                        </ship:OrderLines>
                        <ship:HasOrderComments>?</ship:HasOrderComments>
                        <!--Optional:-->
                        <ship:OrderComments>
                           <!--Zero or more repetitions:-->
                           <ship:OrderComment>
                              <!--Optional:-->
                              <ship:PriceBu>?</ship:PriceBu>
                              <!--Optional:-->
                              <ship:OrderNumber>?</ship:OrderNumber>
                              <ship:CreateDate>?</ship:CreateDate>
                              <!--Optional:-->
                              <ship:CommentCode>?</ship:CommentCode>
                              <!--Optional:-->
                              <ship:CommentText>?</ship:CommentText>
                              <!--Optional:-->
                              <ship:UserId>?</ship:UserId>
                           </ship:OrderComment>
                        </ship:OrderComments>
                     </ship:Order>
                     <ship:HasOrderSourceAddress>?</ship:HasOrderSourceAddress>
                     <ship:UseSourceAddressLookup>?</ship:UseSourceAddressLookup>
                     <!--Optional:-->
                     <ship:SourceAddressLookupCode>?</ship:SourceAddressLookupCode>
                  </ship:DeliveryOrder>
               </ship:DeliveryOrders>
            </ship:ShipmentProcess>
         </ship:ShipmentProcessRequest>
      </ship:SendShipmentProcessRequest>
   </soap:Body>
</soap:Envelope>

    </xsl:template>
</xsl:stylesheet>

请注意,我只映射了前4个元素(直到发起者)休息节点,你可以像我一样映射...你只需要改变xpath ..例如..

对于originator元素,xpath将为: - file/header/originator/text(),对于时区,它将为file/header/timeZone/text(),依此类推......

答案 1 :(得分:0)

基于我在下面的评论中所说的答案之一,这里是一个应该用于此转换的XSLT草案。我没有运行它,因为它没有完成,需要添加许多简单的模板。如果您有任何疑问,请告诉我。

XSLT之间的所有元素都应该匹配,如果您对XSLT有一些了解或者想要学习,那么您将能够完成此XSLT。如果你想忽略一些元素,那么<xsl:templates match="elementname"/>就可以了。

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ship="url"
version="1.0">

<xsl:template match="/">
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" >
        <soap:Header/>
        <soap:Body>
            <xsl:apply-templates/>
        </soap:Body>
    </soap:Envelope>
</xsl:template>

<xsl:template match="file">
    <ship:SendShipmentProcessRequest>
        <ship:ShipmentProcessRequest>
            <ship:ShipmentProcess>
                <xsl:apply-templates/>
            </ship:ShipmentProcess>
        </ship:ShipmentProcessRequest>
    </ship:SendShipmentProcessRequest>
</xsl:template>

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

<xsl:template match="data">
    <ship:DeliveryOrders>
        <xsl:apply-templates/>
    </ship:DeliveryOrders>
</xsl:template>

<xsl:template match="documentType">
    <ship:DocumentType>
        <xsl:apply-templates/>
    </ship:DocumentType>
</xsl:template>

<xsl:template match="version">
    <ship:Version>
        <xsl:apply-templates/>
    </ship:Version>
</xsl:template>

<!-- REST OF THE TEMPLATES FOR THE STUFF BELOW HERE (as the templates above)-->

<ship:CreateDate>?</ship:CreateDate>
<!--Optional:-->
<ship:Originator>?</ship:Originator>
<!--Optional:-->
<ship:TimeZone>?</ship:TimeZone>
<!--Optional:-->
<ship:DateFormat>?</ship:DateFormat>
<!--Optional:-->
<ship:CurrencyFormat>?</ship:CurrencyFormat>
<!--Optional:-->
<ship:WeightUnits>?</ship:WeightUnits>
<!--Optional:-->
<ship:LinearUnits>?</ship:LinearUnits>
<!--Optional:-->
<ship:PriceBuCode>?</ship:PriceBuCode>
<!--Optional:-->
<ship:RouteBuCode>?</ship:RouteBuCode>
<!--Optional:-->
<ship:ServiceProviderAbbreviation>?</ship:ServiceProviderAbbreviation>
<!--Optional:-->
<ship:ServiceProviderId>?</ship:ServiceProviderId>
<!--Optional:-->
<ship:Origin>?</ship:Origin>
<!--Optional:-->
<ship:Destination>?</ship:Destination>

<!-- Continue -->

<xsl:template match="deliveryOrder">
    <ship:DeliveryOrder>
        <xsl:apply-templates/>
    </ship:DeliveryOrder>
</xsl:template>

<xsl:template match="deliveryMethod">
    <ship:DeliveryMethod>
        <xsl:apply-templates/>
    </ship:DeliveryMethod>
</xsl:template>

<!-- same as above -->

<ship:SACId>?</ship:SACId>
<!--Optional:-->
<ship:Operation>?</ship:Operation>
<!--Optional:-->
<ship:DeliveryType>?</ship:DeliveryType>
<ship:IsExchange>?</ship:IsExchange>
<ship:IsMerge>?</ship:IsMerge>
<!--Optional:-->
<ship:MergeOrderNumber>?</ship:MergeOrderNumber>
<ship:TotalArticleQuantity>?</ship:TotalArticleQuantity>
<ship:TotalArticlePackages>?</ship:TotalArticlePackages>
<ship:TotalArticleWeight>?</ship:TotalArticleWeight>
<ship:TotalArticleVolume>?</ship:TotalArticleVolume>

<!-- deeper lvl example -->

<xsl:template match="packages">
    <ship:Packages>
        <xsl:apply-templates/>
    </ship:Packages>
</xsl:template>

<xsl:template match="package">
    <ship:Package>
        <xsl:apply-templates/>
    </ship:Package>
</xsl:template>

<xsl:template match="packageNumber">
    <ship:PackageNumber>
        <xsl:apply-templates/>
    </ship:PackageNumber>
</xsl:template>


<!-- rest templates from the packages -->

<packageWeight>43.89512922</packageWeight>
<packageVolume>0.10083</packageVolume>
<palletNumber />
<mixedPallet>N/A</mixedPallet>

<!-- other deeper lvl elements should be done as the example above -->

<order>
    <priceBu>158</priceBu>
    <number>192963803</number>
    <createDate>01/01/15</createDate>
    <shipmentNo>100052526030</shipmentNo>
    <departureNo/>
    <departureDate>12/31/14 20:06</departureDate>
    <status />
    <deliveryDate>01/10/15 08:00</deliveryDate>
    <deliveryDateFrom>01/10/15 08:00</deliveryDateFrom>
    <deliveryDateTo>01/10/15 22:00</deliveryDateTo>
    <cancelDate />
    <createUserId />
    <vehicleId />
</order>
<orderLines>
    <orderLine>
        <priceBu>158</priceBu>
        <orderNumber />
        <lineNumber>0</lineNumber>
        <articleNumber>40214551</articleNumber>
        <articleQuantity>0</articleQuantity>
        <originalArticleQuantity>1</originalArticleQuantity>
        <articlePackages />
        <articleReferenceNumber />
        <isOutOfStore />
        <receivedDate />
        <storageLocation />
        <receiptDate />
        <moveVehicleId />
        <moveDate />
        <languageCode />
        <number>40214551</number>
        <description>MALM chst/3drw 31 5/8x30 3/4" white N</description>
        <weight>77.27123</weight>
        <volume>0.0744</volume>
    </orderLine>
</orderLines>
<orderComment>
    <priceBu>158</priceBu>
    <orderNumber>192963803</orderNumber>
    <createDate />
    <commentCode>15</commentCode>
    <commentValue>YES</commentValue>
    <commentText>3</commentText>
    <userId />
</orderComment>
<orderComment>
    <priceBu>158</priceBu>
    <orderNumber>192963803</orderNumber>
    <createDate />
    <commentCode>15</commentCode>
    <commentValue>YES</commentValue>
    <commentText>3</commentText>
    <userId />
</orderComment>

</xsl:stylesheet>