开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜