您可以使用哪些 Python 可访问工具从 XML 文档生成 XSD?
我正在寻找一个可以与 Python 很好地配合的工具。 除了我的Python要求之外,我的问题与此相同 一个:
“我正在寻找一种工具,它将获取 XML 实例文档并输出相应的 XSD 架构。”
I'm looking for a tool that will play nicely with Python.
Except for my Python requirement, my question is the same as this one:
"I am looking for a tool which will take an XML instance document and output a corresponding XSD schema."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 PyCharm 文档,PyCharm 有一个用于此目的的工具。程序不能完全将其作为 API 访问。您最好使用 XML Schema Learner 作为单独的程序,因为它是命令行程序(子进程友好!)。
According to the PyCharm docs, PyCharm has a facility for this. This is not exactly accessible by a program as an API. You are probably better off using XML Schema Learner as a separate program since it is a command line program (subprocess friendly!).
您是否正在寻找类似 pyxsd 的东西? (主要用于针对模式进行验证)或者可能是 PyXB? (可以基于 xml 生成类)否则,我认为还没有一个工具可以从 Python 中生成模式。您可以使用 xsd.exe 之类的工具按需执行此操作吗?它必须是程序化的/可重复的吗?
Are you looking for something like pyxsd? (primarily used for validation against a schema) Or maybe PyXB? (can generate classes based on xml) Otherwise, I don't think there's a tool [yet] that will generate the schema from within Python. Can you do it on demand using something like xsd.exe? Does it have to be programmatic/repeatable?
目前,没有任何模块可以在您的 python 程序中运行并执行此转换。但我认为从 XML 创建 XSD 模式的问题是一个工具问题。这是我将使用一次的功能,用于启动模式,但之后我将自己维护该模式。通过读取单个 XML 文件,XSD 生成器将为真实模式创建一个起点,但它无法推断 XSD 提供的所有功能和选项。
基本上,我认为不需要将此转换作为我的代码中的模块运行,从而在每次 XML 更改时生成新的 XSD。毕竟,是架构定义了 XML,而不是相反。
正如最终用户指出的,您可以使用 xsd.exe,但您可能还想查看其他工具,例如 trang(有点旧),适用于 Java 和 stylusstudio(XML 工具)。
Currently, there is no module that will run within your python program and do this conversion. But I see the problem of creating a XSD schema from XML as a tooling problem. It's the kind of functionality that I'll use once, to get a schema started but after that I'll be maintaining the schema myself. From reading a single XML file the XSD generator will create a starting point for a real schema, it cannot infer all the functionality and options offered by XSD.
Basically, I don't see the need to have this conversion run as a module inside of my code, generating new XSDs every time the XML changes. After all, it's the schema that defines the XML not the other way around.
As end-user pointed out you could use xsd.exe but you might also want to look at other tools such as trang (a bit old) for Java and stylusstudio (XML tool).