DTD:如何声明 DTD 必须具有元素值?

发布于 2024-09-28 20:49:12 字数 319 浏览 0 评论 0原文

我想声明我的 DTD 以强制 XML 节点应该有一个值。 例如,我有以下 XML 结构。

<Employees>
   <EmployeeID></EmployeeID>
   <EmployeeName></EmployeeName>
   <EmployeeAddress></EmployeeAddress>
</Employees>

我希望所有 XML 都必须存在 EmployeeID 节点值。所以我想创建一个 DTD 来为 XML 节点提供一个值。

I want to declare my DTD to force the XML node should have a value.
For example I have the following XML structure.

<Employees>
   <EmployeeID></EmployeeID>
   <EmployeeName></EmployeeName>
   <EmployeeAddress></EmployeeAddress>
</Employees>

I want the EmployeeID node value must exist for all the XMLs. So I want to create a DTD to have a value for the XML node.

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

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

发布评论

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

评论(1

心意如水 2024-10-05 20:49:12

您可以将 EmployeeID 作为一个属性吗?然后你可以将它声明为 ID 类型...

否则,不,我认为 DTD 没有任何方法要求其值是非空字符串。

你考虑过RelaxNG吗?它功能强大、灵活且不难学习。

Can you make the EmployeeID be an attribute? Then you could declare it to be of type ID...

Otherwise, no, I don't think there's any way with a DTD to require its value to be a non-empty string.

Have you considered RelaxNG? It's powerful, flexible, and not difficult to learn.

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