gpt4 book ai didi

delphi - 如何使用 Delphi XSD 数据绑定(bind)向导创建 "New"函数

转载 作者:行者123 更新时间:2023-12-03 19:44:00 24 4
gpt4 key购买 nike

根据Embarcadero's documentation

Call the generated New... function to create the TXMLDocument instance for an empty document when you want to create all the data in your application:

var
StockList: IXMLStockListType;
begin
StockList := Newstocklist;

_di_IStockListType StockList = NewStockListType();


但是,在导入 XSD for the Clinical Document Architecture 时 Delphi 生成的 26833 行代码中,我没有得到任何 New... 函数。 .

那么,是什么触发了这些新功能的产生呢?

最佳答案

如果您的 XSD 文档在根级别包含多个 xs:element(或 simpletype、complextype、...)节点,则向导无法确定您的 xml 文档的根级别元素最终是什么。在这种情况下,您必须自己编写 Newxxx 语句:

var yourType : IXMLYourType;
...
yourType := NewXMLDocument.GetDocBinding(
'<root level yourtype tagname>',
TXMLYourType,
'') as IXMLYourType;

尝试导入一个符合xsd的xml文档,会看到生成了newxxx函数。

更新

screenshot

如果您检查要用作根元素的类型的 documentElementType,则会创建 new、load 和 get 函数。如果您不这样做,您将收到以下警告:

warning

关于delphi - 如何使用 Delphi XSD 数据绑定(bind)向导创建 "New"函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9162913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com