结构化XML到Map或Flat XML

时间:2016-03-01 05:17:27

标签: xslt mapping mule

我需要将我的XML上的订单项插入地图或mulesoft中的平面XML。我打算使用XSLT,但我只有单个值而不是多个行项目。我不知道每个功能如何为此工作。任何帮助将不胜感激。

输入

<?xml version="1.0" encoding="utf-8"?><XmlInterchange xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1" xmlns="http://www.edi.com.au/EnterpriseService/">
<InterchangeInfo>
    <Date>2016-02-29T05:56:10.272+05:00</Date>
    <XmlType>LightWeight</XmlType>
    <Source></Source>     
    <Target></Target>
</InterchangeInfo>
<Payload>
    <WhsDockets>
        <WhsDocket>
        <Identifier>                                     
        <Reference>2370519</Reference>
         </Identifier>
    <DocketDetail>
        <WarehouseCode>ROC</WarehouseCode>
        <CustomerReference>3340527</CustomerReference>
        <Units>41</Units>
        <Packages>0</Packages>
        <Pallets>0</Pallets>
        <Weight DimensionType="KG">720</Weight>
        <Cubic DimensionType="M3">5.922</Cubic>
        <TransportInsurance>0.0000</TransportInsurance>
        <ShipperCODAmount>0.0000</ShipperCODAmount>
        <CustomerOrderDetail>
            <OrderType>ORD</OrderType>
            <DateRequired>2015-09-02T00:00:00</DateRequired>
            <Consignee AddressType="CEA">
                <AddressLine1>Cnr Maroochydore and BroadmeadowRds</AddressLine1>
                <CityOrSuburb>MAROOCHYDORE</CityOrSuburb>
                <StateOrProvince>QLD</StateOrProvince>
                <PostCode>4558</PostCode>
                <CompanyName>Bunnings Maroochydore OLD Warehouse</CompanyName>
                <CountryCode>AU</CountryCode>
                <ContactName>The Import Manager</ContactName>
            </Consignee>
        </CustomerOrderDetail>
        <CustomAttributes />
    </DocketDetail>
    <DocketLines>
        <DocketLine>
            <Product>E4342</Product>
            <Description>R 3 5/3 6 175mm x 430mm x 1160mm</Description>
            <QuantityFromClientOrder>5</QuantityFromClientOrder>
            <QuantityActuallyOrdered>5</QuantityActuallyOrdered>
            <ProductUQ>MST</ProductUQ>
            <LineAttributes />
            <LineNumber>1</LineNumber>
            <Confirmation>
                <Lines>
                    <Line>
                        <Quantity>25</Quantity>
                        <QuantityUQ>PAC</QuantityUQ>
                    </Line>
                </Lines>
                <Quantity>25</Quantity>
            </Confirmation>
        </DocketLine>
        <DocketLine>
            <Product>E2281</Product>
            <Description>R 3 5 175mm x 580mm x 1160mm</Description>
            <QuantityFromClientOrder>4</QuantityFromClientOrder>
            <QuantityActuallyOrdered>4</QuantityActuallyOrdered>
            <ProductUQ>MST</ProductUQ>
            <LineAttributes />
            <LineNumber>2</LineNumber>
            <Confirmation>
                <Lines>
                    <Line>
                        <Quantity>16</Quantity>
                        <QuantityUQ>PAC</QuantityUQ>
                    </Line>
                </Lines>
                <Quantity>16</Quantity>
            </Confirmation>
        </DocketLine>
    </DocketLines>
   </WhsDocket>
</WhsDockets>
</Payload></XmlInterchange>

我需要展平XML,但要使用Litem项目详细信息以及每个项目的参考编号。

输出

<?xml version="1.0" encoding="utf-8"?><Items>
    <LineItem>
        <Date/>
        <Order>2370519</Order>
        <Client>Bunnings Maroochydore OLD Warehouse</Client>
        <Product>E2281</Product>
        <Description>R 3 5 175mm x 580mm x 1160mm</Description>
        <Quantity>4</Quantity>
        <UOM>MST</UOM>
        <Warebouse>ROC</Warebouse>
        <Carrier>Deluxe</Carrier>
    </LineItem>
</Items>

1 个答案:

答案 0 :(得分:1)

您是否看过DataWeave将其从当前的xml转换为新的xml?

https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-examples#xml-basic