DTD 根元素
是否可以在内部定义哪个元素将是 DTD 中的根元素。换句话说,当 DTD 位于单独的文件中时是否可以定义根元素?
Is it possible to define which element will be the root element in a DTD internally. In other words, Is it possible to define the root element when DTD is in a separate file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根元素由
DOCTYPE
声明确定。根元素可以是 DTD 中的任何元素。例如,在下面的 DTD (test.dtd) 中,
book
通常是根元素:但是,如果我们在 doctype 中使用
section
,section 是根元素:
我在外部 DTD 中使用了
DOCTYPE
声明来直接指定根元素,但我认为规范不允许这样做。我所做的是将DOCTYPE
保留在外部 DTD 中,并从 XML 文件中删除DOCTYPE
。我能够在我使用的程序的命令行上将 DTD 与 XML 文件关联起来。The root element is determined by the
DOCTYPE
declaration. The root element can be any element in the DTD.For example in the DTD below (test.dtd),
book
would normally be the root element:However, if we use
section
in the doctype,section
is the root element:I've used
DOCTYPE
declarations in the external DTD to directly specify the root element, but I don't think that is allowed by the spec. What I did was keep theDOCTYPE
in the external DTD and remove theDOCTYPE
from the XML file. I was able to associate the DTD with the XML file on the command line of the program I was using.