开发者

DTD: How to declare a DTD to must have a element value?

开发者 https://www.devze.com 2023-01-21 08:25 出处:网络
I want to declare my DTD to force the XML node should have a value. For example I have the following XML structure.

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 th开发者_Go百科e XML node.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消