Progress OpenEdge XML 可选子节点

发布于 2025-01-10 19:00:12 字数 2765 浏览 0 评论 0原文

我需要有关如何使用 write-xml 编写以下 XML 的建议? 这可能吗?谢谢

注意最后一个材质节点有不同的元素。在编写输出时如何使元素可选和“显示/不显示”?

def temp-table ttMaterials no-undo       serialize-name "Materials" 
  field MatsID                  as int   serialize-hidden.

def temp-table ttMaterial  no-undo       serialize-name "Material" 
  field MatsID                  as int   serialize-hidden
  field MaterialNumber          as char
  field PalletNumber            as char
  field Quantity                as char
  field UnitOfMeasure           as char
  field StorageLocation         as char
  field OperationCode           as char
  field ReasonCode              as char
  field CancellationFlag        as char
  field ItemNo                  as char.
  
def dataset dsMaterial xml-node-name "ns1:Message" for 
  ttMaterials, ttMaterial.
  data-relation Rel1 for ttMaterials, ttMaterial nested relation-fields(MatsID, MatsID).


<?xml version="1.0"?>
<ns1:Message xmlns:ns1="http://google.envelope">
  <Materials>
    <Material>
      <MaterialNumber>00111</MaterialNumber>
      <PalletNumber>1888845001</PalletNumber>
      <Quantity>91.0000000000</Quantity>
      <UnitOfMeasure>PAC</UnitOfMeasure>
      <StorageLocation>700</StorageLocation>
      <OperationCode>101</OperationCode>
      <ReasonCode/>
      <CancellationFlag>false</CancellationFlag>
      <ItemNo>10</ItemNo>
    </Material>
    <Material>
      <MaterialNumber>00112</MaterialNumber>
      <PalletNumber>45828760</PalletNumber>
      <Quantity>58.3100000000</Quantity>
      <UnitOfMeasure>PAC</UnitOfMeasure>
      <StorageLocation>700</StorageLocation>
      <OperationCode>543</OperationCode>
      <ReasonCode/>
      <CancellationFlag>false</CancellationFlag>
      <ItemNo>10</ItemNo>
    </Material>
    <Material>
       <FromMaterialNumber>000000000000063299</FromMaterialNumber>
       <ToMaterialNumber>000000000000063299</ToMaterialNumber>
       <FromPalletNumber>81592826</FromPalletNumber>
       <ToPalletNumber>81592826</ToPalletNumber>
       <Quantity>8</Quantity>
       <UnitOfMeasure>PAC</UnitOfMeasure>
       <FromStorageLocation>300</FromStorageLocation>
       <ToStorageLocation>300</ToStorageLocation>
       <OperationCode>551</OperationCode>
       <ReasonCode>12</ReasonCode>
       <CancellationFlag>false</CancellationFlag>
    </Material>
  </Materials>
</ns1:Message>

I need a suggestion on how to write the following XML using write-xml?
is this possible? thank you

Notice the last material node has a different elements. How can I made elements optional and "show/notShow" when writing the output?

def temp-table ttMaterials no-undo       serialize-name "Materials" 
  field MatsID                  as int   serialize-hidden.

def temp-table ttMaterial  no-undo       serialize-name "Material" 
  field MatsID                  as int   serialize-hidden
  field MaterialNumber          as char
  field PalletNumber            as char
  field Quantity                as char
  field UnitOfMeasure           as char
  field StorageLocation         as char
  field OperationCode           as char
  field ReasonCode              as char
  field CancellationFlag        as char
  field ItemNo                  as char.
  
def dataset dsMaterial xml-node-name "ns1:Message" for 
  ttMaterials, ttMaterial.
  data-relation Rel1 for ttMaterials, ttMaterial nested relation-fields(MatsID, MatsID).


<?xml version="1.0"?>
<ns1:Message xmlns:ns1="http://google.envelope">
  <Materials>
    <Material>
      <MaterialNumber>00111</MaterialNumber>
      <PalletNumber>1888845001</PalletNumber>
      <Quantity>91.0000000000</Quantity>
      <UnitOfMeasure>PAC</UnitOfMeasure>
      <StorageLocation>700</StorageLocation>
      <OperationCode>101</OperationCode>
      <ReasonCode/>
      <CancellationFlag>false</CancellationFlag>
      <ItemNo>10</ItemNo>
    </Material>
    <Material>
      <MaterialNumber>00112</MaterialNumber>
      <PalletNumber>45828760</PalletNumber>
      <Quantity>58.3100000000</Quantity>
      <UnitOfMeasure>PAC</UnitOfMeasure>
      <StorageLocation>700</StorageLocation>
      <OperationCode>543</OperationCode>
      <ReasonCode/>
      <CancellationFlag>false</CancellationFlag>
      <ItemNo>10</ItemNo>
    </Material>
    <Material>
       <FromMaterialNumber>000000000000063299</FromMaterialNumber>
       <ToMaterialNumber>000000000000063299</ToMaterialNumber>
       <FromPalletNumber>81592826</FromPalletNumber>
       <ToPalletNumber>81592826</ToPalletNumber>
       <Quantity>8</Quantity>
       <UnitOfMeasure>PAC</UnitOfMeasure>
       <FromStorageLocation>300</FromStorageLocation>
       <ToStorageLocation>300</ToStorageLocation>
       <OperationCode>551</OperationCode>
       <ReasonCode>12</ReasonCode>
       <CancellationFlag>false</CancellationFlag>
    </Material>
  </Materials>
</ns1:Message>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑轻吟梦一曲 2025-01-17 19:00:12

您可以使用 write-xml 方法并确保此对于您需要隐藏的数据来说是正确的。

dataset dsMaterial:write-xml(
  'longchar',
  lcxml,
  true, // formatted
  ?,    // encoding
  ?,    // schema-location
  ?,    // write-xml-schema
  ?,    // min-xml-schema
  ?,    // write-before-image
  true  // omit-initial-values
).
message string( lcxml ).

You can make use of parameter 9 (omit-initial-values) of the write-xml method and ensure that this is true for the data you need to hide.

dataset dsMaterial:write-xml(
  'longchar',
  lcxml,
  true, // formatted
  ?,    // encoding
  ?,    // schema-location
  ?,    // write-xml-schema
  ?,    // min-xml-schema
  ?,    // write-before-image
  true  // omit-initial-values
).
message string( lcxml ).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文