COBOL 中的 XML,具有嵌套表和不同的子项
是否可以使用 XML GENERATE 创建具有不同大小的多层嵌套元素的 XML?
例如:
01 SOURCE-REC.
05 REPEATING-PARENT OCCURS 5 TIMES.
10 PARENT-NAME PIC X(7).
10 CHILD-COUNT PIC 9.
10 REPEATING-CHILD OCCURS 1 TO 5 TIMES
DEPENDING ON CHILD-COUNT.
15 CHILD-NAME PIC X(6).
使用 Enterprise Cobol v4.1 编译此结果:
IGYGR1263-S“OCCURS DEPENDING ON”对象“CHILD-COUNT”被定义为表 元素。 “取决于”短语被丢弃。
IGYGR1116-S 表“REPEATING-CHILD”的“DEPENDING ON”对象无效。这 “取决于”短语被丢弃。
并非所有父母都会拥有相同数量的孩子。如何解决这个问题?
编辑:我想从本质上讲,这并不是一个真正的 XML 问题。我在试图构建工作存储时遇到了困难,我后来希望将其输入到 XML GENERATE 中。
Is it possible to use XML GENERATE to create XML with multi-level nested elements of different sizes?
For example:
01 SOURCE-REC.
05 REPEATING-PARENT OCCURS 5 TIMES.
10 PARENT-NAME PIC X(7).
10 CHILD-COUNT PIC 9.
10 REPEATING-CHILD OCCURS 1 TO 5 TIMES
DEPENDING ON CHILD-COUNT.
15 CHILD-NAME PIC X(6).
Compiling this using Enterprise Cobol v4.1 yields:
IGYGR1263-S "OCCURS DEPENDING ON" object "CHILD-COUNT" was defined as a table
element. The "DEPENDING ON" phrase was discarded.
IGYGR1116-S The "DEPENDING ON" object for table "REPEATING-CHILD" was invalid. The
"DEPENDING ON" phrase was discarded.
Not all parents are going to have the same number of children. How can this be addressed?
Edit: I suppose at its heart, this isn't really an XML question. I hit a wall just trying to build the working storage that I later hope to feed into XML GENERATE.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
第一个答案摘要:你无法定义
COBOL 中的复杂 ODO,其中包含 ODO 对象
在一个表内。因此 XML 是不可能的
GENERATE 为每个生成不同数量的“子代”
“父母”的出现。你必须忍受固定的生活
表维度和空节点。
第二轮:您是否考虑过重新解析/重新构建
生成XML字符串以消除空节点?这
可能听起来有点奇怪,但可能并非如此
难的。看看下面的程序
它产生的输出...
Summary of first answer: You cannot define
a complex ODO in COBOL where the ODO object is contained
within a table. Consequently it is not possible for XML
GENERATE to produce a varying number of "childern" for each
occurance of a "parent". You have to live with fixed
table dimensions and empty nodes.
Round two: Have you considered re-parsing/re-constructing the
generated XML string to eliminate the empty nodes? This
may sound a little odd but it may not be all that
difficult. Have a look at the following program and
the output it produces...
我认为问题在于必须定义 CHILD-COUNT
在传递给 XML GENERATE 的记录结构之外。像这样的东西:
然后在 XML GENERATE 之前你必须做一些事情
做作的比如:
如果您想保留 REPEATING-CHILD 出现的次数,
这可能不是您想要看到的,因为它几乎
意味着您必须为每个人拥有相同数量的受抚养子女
REPEATING-PARENT 出现。
I think the problem is that the CHILD-COUNT must be defined
outside of the record structure passed to XML GENERATE. Something like:
Then just before the XML GENERATE you would have to do something
hokey such as:
if you want to retain the number of occurs for REPEATING-CHILD
This is probably not what you wanted to see because it pretty much
means you must to have the same number of dependant children for each
REPEATING-PARENT occurance.
我认为你应该完全失去依赖。它不会节省内存,并且您可以通过确保它们的下标在 1 到相应的 CHILD-COUNTER 范围内来轻松寻址有效的 REPEATING-CHILD 项。
I think you should lose the DEPENDING ON altogether. It doesn't save memory, and you can just as easily address valid REPEATING-CHILD items by making sure their subscripts are in the range from 1 to the corresponding CHILD-COUNTER.