XSD 格式问题

问题描述 投票:0回答:1

我正在使用 Azure 逻辑应用从 MS Dynamics Business Central 检索数据。该数据使用 XSD 格式转换为 XML。然后 XML 被发送到外部系统。

我设法使大部分流程正常运行,但我仍然遇到 XSD 部分的问题。数据由标头(此部分仅在 xml 顶部出现一次)以及一个或多个订单行组成。订单行应该出现多次,但多个订单行的数据会添加到一个块中。

我已经添加了 xsd 的示例、应该显示的 xml 以及现在显示的 xml。

XSD

<xs:element name="orderlines">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="orderline" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="type" type="xs:string"/>
                        <xs:element name="whs" type="xs:string"/>
                        <xs:element name="qty" type="xs:string"/>
                        <xs:element name="partnr" type="xs:string"/>
                        <xs:element name="snr" type="xs:string"/>
                        <xs:element name="refnr" type="xs:string"/>
                        <xs:element name="origincountry" type="xs:string"/>
                        <xs:element name="commercialvalue" type="xs:string"/>
                        <xs:element name="commoditycode" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>

符合预期的 XML

<orderlines>
    <orderline>
        <type>REPLENISH</type>
        <whs>tes</whs>
        <qty>50</qty>
        <partnr>201.9004.8</partnr>
        <snr></snr>
        <refnr>efa79477-dfec-ee11-a1fd-7c1e52208373</refnr>
        <origincountry></origincountry>
        <commercialvalue>191.25</commercialvalue>
        <commoditycode></commoditycode>
    </orderline>
    <orderline>
        <type>REPLENISH</type>
        <whs>tes</whs>
        <qty>1</qty>
        <partnr>300.1351.1</partnr>
        <snr></snr>
        <refnr>b50570f3-7e7a-ef11-a671-6045bd999b21</refnr>
        <origincountry></origincountry>
        <commercialvalue>50.75</commercialvalue>
        <commoditycode></commoditycode>
    </orderline>
    <orderline>
        <type>REPLENISH</type>
        <whs>tes</whs>
        <qty>50</qty>
        <partnr>201.9004.8</partnr>
        <snr></snr>
        <refnr>1538e880-f9f0-ee11-a1fd-0022489bf1a3</refnr>
        <origincountry></origincountry>
        <commercialvalue>191.24</commercialvalue>
        <commoditycode></commoditycode>
    </orderline>
</orderlines>

我现在得到的 XML 输出

<orderlines>
    <orderline>
        <type>["REPLENISH"]</type>
        <whs>["tes","tes","tes","tes"]</whs>
        <qty>[50,1,50,50]</qty>
        <partnr>["201.9004.8","300.1351.1","201.9004.8","201.9004.8"]</partnr>
        <snr>[]</snr>
        <refnr>
            ["efa79477-dfec-ee11-a1fd-7c1e52208373","b50570f3-7e7a-ef11-a671-6045bd999b21","1538e880-f9f0-ee11-a1fd-0022489bf1a3","4438e880-f9f0-ee11-a1fd-0022489bf1a3"]</refnr>
        <origincountry>[]</origincountry>
        <commercialvalue>[191.25,50.75,191.24,191.24]</commercialvalue>
        <commoditycode>[]</commoditycode>
    </orderline>
</orderlines>

希望得到一些帮助,提前致谢!

xml xsd workflow azure-logic-apps
1个回答
0
投票

我已在给定架构的

XML compose with schema
操作中使用了以下输入数据。

输入数据:-

[
    {
      "type": "REPLENISH",
      "whs": "tes",
      "qty": "50",
      "partnr": "201.9004.8",
      "snr": "",
      "refnr": "efa79477-dfec-ee11-a1fd-7c1e52208373",
      "origincountry": "",
      "commercialvalue": "191.25",
      "commoditycode": ""
    },
    {
      "type": "REPLENISH",
      "whs": "tes",
      "qty": "1",
      "partnr": "300.1351.1",
      "snr": "",
      "refnr": "b50570f3-7e7a-ef11-a671-6045bd999b21",
      "origincountry": "",
      "commercialvalue": "50.75",
      "commoditycode": ""
    },
    {
      "type": "REPLENISH",
      "whs": "tes",
      "qty": "50",
      "partnr": "201.9004.8",
      "snr": "",
      "refnr": "1538e880-f9f0-ee11-a1fd-0022489bf1a3",
      "origincountry": "",
      "commercialvalue": "191.24",
      "commoditycode": ""
    },
    {
      "type": "REPLENISH",
      "whs": "tes",
      "qty": "50",
      "partnr": "201.9004.8",
      "snr": "",
      "refnr": "4438e880-f9f0-ee11-a1fd-0022489bf1a3",
      "origincountry": "",
      "commercialvalue": "191.24",
      "commoditycode": ""
    }
]

架构:-

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="orderlines">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="orderline" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="type" type="xs:string"/>
                            <xs:element name="whs" type="xs:string"/>
                            <xs:element name="qty" type="xs:string"/>
                            <xs:element name="partnr" type="xs:string"/>
                            <xs:element name="snr" type="xs:string"/>
                            <xs:element name="refnr" type="xs:string"/>
                            <xs:element name="origincountry" type="xs:string"/>
                            <xs:element name="commercialvalue" type="xs:string"/>
                            <xs:element name="commoditycode" type="xs:string"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

enter image description here

我得到了预期的回应。

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<orderlines>
    <orderline>
        <type>REPLENISH</type>
        <whs>tes</whs>
        <qty>50</qty>
        <partnr>201.9004.8</partnr>
        <snr></snr>
        <refnr>efa79477-dfec-ee11-a1fd-7c1e52208373</refnr>
        <origincountry></origincountry>
        <commercialvalue>191.25</commercialvalue>
        <commoditycode></commoditycode>
    </orderline>
    <orderline>
        <type>REPLENISH</type>
        <whs>tes</whs>
        <qty>1</qty>
        <partnr>300.1351.1</partnr>
        <snr></snr>
        <refnr>b50570f3-7e7a-ef11-a671-6045bd999b21</refnr>
        <origincountry></origincountry>
        <commercialvalue>50.75</commercialvalue>
        <commoditycode></commoditycode>
    </orderline>
    <orderline>
        <type>REPLENISH</type>
        <whs>tes</whs>
        <qty>50</qty>
        <partnr>201.9004.8</partnr>
        <snr></snr>
        <refnr>1538e880-f9f0-ee11-a1fd-0022489bf1a3</refnr>
        <origincountry></origincountry>
        <commercialvalue>191.24</commercialvalue>
        <commoditycode></commoditycode>
    </orderline>
    <orderline>
        <type>REPLENISH</type>
        <whs>tes</whs>
        <qty>50</qty>
        <partnr>201.9004.8</partnr>
        <snr></snr>
        <refnr>4438e880-f9f0-ee11-a1fd-0022489bf1a3</refnr>
        <origincountry></origincountry>
        <commercialvalue>191.24</commercialvalue>
        <commoditycode></commoditycode>
    </orderline>
</orderlines>
© www.soinside.com 2019 - 2024. All rights reserved.