xmlement属性组

cidc1ykv  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(214)

我们能够生成如下所示的xml结构,其中数据是线性的,没有关于模型的分组。

<transaction>
    <header>
        <trantype>siv</trantype>
        <options>ModelMasterEdit</options>
    </header>
    <detail>
        <record>
            <Description>test_060420</Description>
            <Details>Test Details</Details>
            <Canonical>A1863</Canonical>
            <Classification>PH</Classification>
            <Tree>XM</Tree>
            <Manufacturer>Apple</Manufacturer>
            <Forecast>Apple Smart Phones</Forecast>
            <Category>Cellular Phones</Category>
            <SerialCaption>Serial Number</SerialCaption>
            <Description>test_060421</Description>
            <Details>Test Details</Details>
            <Canonical>A1863</Canonical>
            <Classification>PH</Classification>
            <Tree>XM</Tree>
            <Manufacturer>Apple</Manufacturer>
            <Forecast>Apple Smart Phones</Forecast>
            <Category>Cellular Phones</Category>
            <SerialCaption>Serial Number</SerialCaption>
        </record>
    </detail>
</transaction>

但是,我们需要以下格式的输出,根据模型编号对模型属性进行分组

<transaction>
    <header>
        <trantype>siv</trantype>
        <options>ModelMasterEdit</options>
    </header>
    <detail>
        <record>
            <Description>test_060420</Description>
            <Details>Test Details</Details>
            <Canonical>A1863</Canonical>
            <Classification>PH</Classification>
            <Tree>XM</Tree>
            <Manufacturer>Apple</Manufacturer>
            <Forecast>Apple Smart Phones</Forecast>
            <Category>Cellular Phones</Category>
            <SerialCaption>Serial Number</SerialCaption>
        </record>
        <record>
            <Description>test_060421</Description>
            <Details>Test Details</Details>
            <Canonical>A1863</Canonical>
            <Classification>PH</Classification>
            <Tree>XM</Tree>
            <Manufacturer>Apple</Manufacturer>
            <Forecast>Apple Smart Phones</Forecast>
            <Category>Cellular Phones</Category>
            <SerialCaption>Serial Number</SerialCaption>
        </record>
    </detail>
</transaction>

我们创建了下面的sql查询来生成第一个xml,但无法生成所需的第二个xml

SELECT XMLELEMENT ("transaction",XMLELEMENT("header", XMLELEMENT ("trantype", 'siv'), XMLELEMENT ("options", 'ModelMasterEdit')),
        XMLELEMENT ( "detail",
        XMLELEMENT (
           "record",
           XMLAGG (
               XMLELEMENT (evalname(attribute_name), attribute_value)))))
              FROM XXCMST_INV_CMT_PRODUCT_TBL i
                 WHERE     soa_instance_id = 64202001
                 AND source_system = 'EIS'

表格数据:

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题