如何创造“新”使用 Delphi XSD 数据绑定向导的函数

发布于 2025-01-03 03:00:39 字数 574 浏览 1 评论 0原文

根据 Embarcadero 文档

当您想要创建应用程序中的所有数据时,调用生成的 New... 函数为空文档创建 TXMLDocument 实例:

<前><代码>变量 库存列表:IXMLStockListType; 开始 库存列表 := 新库存列表; _di_IStockListType StockList = NewStockListType();

但是,我在 Delphi 生成的 26833 行代码中没有得到任何 New... 函数导入临床文档的 XSD 时架构

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

According to 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();

However, I don't get any New... functions in the 26833 lines of code Delphi generated when importing the XSD for the Clinical Document Architecture .

So, what triggers the generation of these New functions?

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

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

发布评论

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

评论(1

年少掌心 2025-01-10 03:00:39

如果您的 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

If your XSD document contains multiple xs:element (or simpletype,complextype,...) nodes at the root level, the wizard can't determine what the root level element will eventually be of your xml document. In that case you must write the Newxxx statement yourself:

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

Try to import an xml document that adheres to the xsd and you will see that the newxxx function will be generated.

UPDATE

screenshot

If you check the documentElementType for the Type you want to use as root element, the new, load and get functions are created. If you don't do that you will get this warning:

warning

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文