.Net 中有没有办法以编程方式从现有 XML 文件生成 DTD?
我一直在查看 System.Xml 命名空间,但没有看到任何支持这一点的内容。 有谁知道它是否内置于.Net中,或者我是否必须获得第三方库才能做到这一点?
注意:我希望它像生成 xsd 一样简单,但这不适用于我的具体情况。
I've been looking around the System.Xml namespace, but don't see anything that would support this. Does anyone know if it's built into .Net, or would I have to obtain a third party library to do it?
NOTE: I wish it were as simple as generating an xsd, but that won't do for my specific situation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
做起来很容易,但要使其有用却很难。
DTD 是一种语法。 生成只生成给定 XML 文件而不生成其他文件的语法是很简单的。 这在实际中当然是没有用的。 你可能需要的是创建一个生成“像这样”的文件的语法,这是一个人工智能难题。
编辑:这个问题被称为“语法归纳”或“语法推理”。
It would be very easy to do, but very hard to make it useful.
DTD is a grammar. It is trivial to generate a grammar that generates just the given XML file and no other. This is of course useless in practice. What you probably need is to create a grammar that generates files "like this one", and this is a hard AI problem.
Edit: This problem is known as "Grammar Induction" or "Grammar Inference".
我不确定 DTD,但您可以使用 Xsd.exe 工具。 它通常位于以下目录:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\xsd.exe
I'm not sure about DTD but you can generate XSD files from an xml file using the Xsd.exe tool. It usually lives in the following directory:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\xsd.exe
那么,xsd.exe 应该能够为您提供一个 xsd。 对于 dtd 方面,xmlpad3 声称能够做到这一点(并且是免费的)。 我没有尝试过,所以我不能保证。
Well, xsd.exe should be able to get you an xsd. For the dtd side, xmlpad3 claims to be able to do this (and is free). I haven't tried, so I can't vouch for it.