调查:您如何使用 ID/IDREF? (或键/键引用)
我对人们如何使用此功能感兴趣:什么领域、什么关系(如果调查问题不合适,敬请原谅)。
XML 自然地使用包含来表示树; 但它也可以使用引用 ID 的 IDREF 来表示图形:许多元素可以引用同一个元素(多引用); 嵌套元素可以引用祖先(循环)。 使用 ID 和 IDREF 也可能很方便,因此 XML 结构可以匹配另一种存储格式,例如数据库外键。
您用 ID/IDREF 代表什么?
编辑还包括 XML 架构中的
。
I'm interested in how people use this feature: what domain, what relationships (apologies if survey questions aren't appropriate).
XML represents trees naturally using containment; but it can also represent graphs, using IDREFs that refer to IDs: many elements can refer to the same element (multi-ref); and a nested element can refer to an ancestor (cycle). It might also be convenient to use IDs and IDREFs so the XML structure matches another storage format, e.g. database foreign keys.
What do you represent with ID/IDREF?
EDIT Also including <key>/<keyref>
from XML Schema.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我主要使用 XML 进行发布,而不是存储数据,因此我使用 ID/IDREF 进行链接和交叉引用(其中具有 IDREF 的元素的内容将从具有 ID 的元素中提取)。
I mostly use XML for publishing, not to store data, so I use ID/IDREFs for links and cross-references (where the content of the element with the IDREF will be pulled from the element with the ID).
我使用 XML 进行序列化,因此我使用 ID/IDREF 来打破循环并防止重复序列化。 我还考虑过使用它来“预声明”对附加到我的图形但未序列化为图形的一部分的外部对象的引用。
这些方法的问题在于,很难引导序列化框架(即 JAX-B)在运行时动态确定对象是否应该就地序列化或作为引用序列化。
I use XML for serialization, so I use ID/IDREF to break cycles and prevent duplicate serializations. I've also considered using it to "pre-declare" references to external objects which are attached to my graph but not serialized as part of it.
The problem with these approaches is that it's difficult to coax serialization frameworks (i.e. JAX-B) into dynamically determining, at runtime, if an object should be serialized in-place or as a reference.