如何可视化 XML 模式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2486758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to visualize an XML schema?
提问by matt
I have made an XML Schema - all the code basically - and was wondering if there is a way that the code can generate something like this:
我已经制作了一个 XML 模式 - 基本上所有的代码 - 并且想知道是否有一种方法可以让代码生成这样的东西:


If so how can I do it?
如果是这样,我该怎么做?
回答by Erik Sj?lund
The open source command line java application xsdvicreates an interactive diagram in SVG format from an XML Schema Definition. The generated SVG file can be displayed by a modern web browser where the user can expand and collapse the tree by mouse clicking.
开源命令行 java 应用程序xsdvi根据 XML 模式定义创建 SVG 格式的交互式图表。生成的 SVG 文件可以通过现代 Web 浏览器显示,用户可以通过单击鼠标来展开和折叠树。
Here is an example of a generated diagram
这是生成的图表的示例
http://xsdvi.sourceforge.net/ipo.svg
http://xsdvi.sourceforge.net/ipo.svg
The software can be downloaded from
该软件可以从
http://sourceforge.net/projects/xsdvi/
http://sourceforge.net/projects/xsdvi/
It can be run as follows (assuming Java is installed and java.exeis in the path):-
它可以按如下方式运行(假设 Java 已安装并java.exe在路径中):-
- Go to the
dist/libfolder. - Run the following command
java -jar xsdvi.jar <input1.xsd> [<input2.xsd> [<input3.xsd> ...]] [style]
- 转到
dist/lib文件夹。 - 运行以下命令
java -jar xsdvi.jar <input1.xsd> [<input2.xsd> [<input3.xsd> ...]] [style]
回答by toddmo
XSD Diagramis free (GNU open license), doesn't need to be built, and gives an interactive diagram. You just open the file and Add the types you want on the (initially blank) diagram. Pretty straight forward.
XSD 图表是免费的(GNU 开放许可证),不需要构建,并提供交互式图表。您只需打开文件并在(最初为空白)图表上添加您想要的类型。很直接。
回答by Marcus Junius Brutus
The Oracle JDeveloper 11gbuilt-in viewer is in my view superior to the one available for Eclipse(which, in addition to other unfavourable comparison points I could only get to install for Indigobut not for Juno). If I am not mistaken Oracle makes the JDeveloper available for free(only requires registration at the OTN).
在我看来,Oracle JDeveloper 11g内置查看器优于可用于Eclipse 的查看器(除了其他不利的比较点之外,我只能为Indigo安装而不能为Juno安装)。如果我没记错的话,Oracle会免费提供 JDeveloper(只需要在 OTN 上注册)。


回答by jelies
You can use XMLGrid's Online viewer which provides a great XSD support and many other features:
您可以使用XMLGrid的在线查看器,它提供了强大的 XSD 支持和许多其他功能:
- Display XML data in an XML data grid.
- Supports XML, XSL, XSLT, XSD, HTML file types.
- Easy to modify or delete existing nodes, attributes, comments.
- Easy to add new nodes, attributes or comments.
- Easy to expand or collapse XML node tree.
- View XML source code.
- 在 XML 数据网格中显示 XML 数据。
- 支持 XML、XSL、XSLT、XSD、HTML 文件类型。
- 易于修改或删除现有节点、属性、注释。
- 易于添加新节点、属性或注释。
- 易于展开或折叠 XML 节点树。
- 查看 XML 源代码。
Screenshot:
截屏:


回答by datentyp
On Linux (with mono, available via apt-geton Debian) and Windows:
在 Linux(带有单声道,可通过apt-getDebian 获得)和 Windows 上:
- XSDDiagram(runs on Mono as well)
- XSDDiagram(也在 Mono 上运行)
If you are on Windows I recommend you have a look at:
如果您使用的是 Windows,我建议您查看:
Both tools are free and both are able to provide similar visualizations as shown in your example.
这两种工具都是免费的,并且都能够提供类似的可视化效果,如您的示例所示。
回答by marc_s
If you need a simple, more text-oriented documentation of your XSD, check out xs3p- a XSLT stylesheet that will transform your XSD into more readable HTML format. Quite nice, and totally free.
如果您需要一个简单的、更面向文本的 XSD 文档,请查看xs3p- 一个 XSLT 样式表,它将您的 XSD 转换为更易读的 HTML 格式。相当不错,而且完全免费。
If that's not enough, check out some of the commercial tools out there - I personally prefer the Liquid XML Studio- not as expensive as others, and quite as capable!
如果这还不够,请查看一些商业工具 - 我个人更喜欢Liquid XML Studio- 不像其他工具那么昂贵,而且功能强大!
回答by APC
That picture is generated from a XML Schema editing tool, such as Altova's XMLSpy.
该图片是从 XML 模式编辑工具生成的,例如Altova 的 XMLSpy。
There are a number of XML tools around, all of which will include a Graphical XSD Viewer. I mentioned XML Spy simply because it is the brand leader. Also many general IDEs like Eclipse, Visual Studio and Oracle JDeveloper will be able to do this trick.
周围有许多 XML 工具,所有这些工具都包括图形 XSD 查看器。我提到 XML Spy 只是因为它是品牌领导者。Eclipse、Visual Studio 和 Oracle JDeveloper 等许多通用 IDE 也能做到这一点。
回答by Leonid Rudy
We offer a tool called DocFlex/XML XSDDocthat allows you to enjoy both things at once:
我们提供了一个名为DocFlex/XML XSDDoc的工具,让您可以同时享受这两件事:
- To have diagram represetation of your XML schema
- To have all those diagrams embedded (and hyperlinked) in a highly sophisticated XML schema documentation
- 对您的 XML 模式进行图表表示
- 将所有这些图表嵌入(和超链接)在高度复杂的 XML 模式文档中
The diagrams in fact are generated not by us, but by Altova XMLSpy. We implemented an Integration with XMLSpy(with the full support of all diagram hyperlinks):
这些图表实际上不是由我们生成的,而是由Altova XMLSpy 生成的。我们实现了与 XMLSpy的集成(完全支持所有图表超链接):


Here you can see the full this doc: http://www.filigris.com/docflex-xml/xsddoc/examples/html/XMLSchema/index.html
在这里你可以看到完整的这个文档:http: //www.filigris.com/docflex-xml/xsddoc/examples/html/XMLSchema/index.html
The whole thing provides a functionality not offered by any single vendor right now on the market!
整个事情提供了目前市场上任何一家供应商都没有提供的功能!
Some our customers were so impressed that they purchased an extra license for XMLSpy only because of our tool. (That's no joke!)
我们的一些客户印象深刻,他们购买 XMLSpy 的额外许可证仅仅是因为我们的工具。(这不是开玩笑!)
Currently, we've also implemented similar integrations with other XML editors:
目前,我们还与其他 XML 编辑器实现了类似的集成:


See: http://www.filigris.com/docflex-xml/OxygenXML/demo/html/xslt20/index.html
请参阅:http: //www.filigris.com/docflex-xml/OxygenXML/demo/html/xslt20/index.html


See: http://www.filigris.com/docflex-xml/LiquidXML/demo/html/XMLSchema/index.html
请参阅:http: //www.filigris.com/docflex-xml/LiquidXML/demo/html/XMLSchema/index.html
Concerning what all those diagrams depict... Essentially, they are all about content model of XSD elements (as well as other XSD components that lead to elements: complexTypes, element/attribute groups). It seems, there are two approaches here:
关于所有这些图所描绘的内容......本质上,它们都是关于 XSD 元素的内容模型(以及导致元素的其他 XSD 组件:complexTypes、元素/属性组)。看来,这里有两种方法:
- To show what a result content model (represented by the given component) would look. That's the approach of XMLSpy.
- To show how a particular content model (of the given component) was derived from other components. That's the approach of <oXygen/> XML and Liquid XML.
- 显示结果内容模型(由给定组件表示)的外观。这就是 XMLSpy 的方法。
- 展示(给定组件的)特定内容模型是如何从其他组件派生而来的。这就是 <oXygen/> XML 和 Liquid XML 的方法。
I personally believe that the diagrams generated by XMLSpy are more useful.
我个人认为 XMLSpy 生成的图表更有用。
Yet, there were no attempts so far (at least known to me) to depict graphically anything else contained in XML schemas, although one can imagine many...
然而,到目前为止(至少我知道)还没有尝试以图形方式描述 XML 模式中包含的任何其他内容,尽管人们可以想象很多......
回答by ambidexterous
Visual Studio 2013 has a pretty cool visualizer built in.
Visual Studio 2013 内置了一个非常酷的可视化工具。
File -> Open -> File pick your .xsd and then drag elements from XML Schema Explorer onto the designer surface.
File -> Open -> File 选择您的 .xsd,然后将元素从 XML Schema Explorer 拖到设计器图面上。
回答by 0x6B6F77616C74
Here is my approach- download the freemindand CAM XML Template Editor.
Then open CAM XML, create new Template from XML, View -> View Template As Mind Map
Pros of this solution:
这是我的方法 - 下载freemind和CAM XML 模板编辑器。然后打开 CAM XML,从 XML 创建新模板,查看 -> 查看模板作为思维导图
此解决方案的优点:
- It works locally, so secret files can be processed,
- totally free of charge,
- open source.
- 它在本地工作,因此可以处理秘密文件,
- 完全免费,
- 开源。
Cons:
缺点:
- Quite unstable with large (more than 20sh MB) files.
- 大(超过 20sh MB)文件相当不稳定。

