[xml] How to visualize an XML schema?

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:

enter image description here

If so how can I do it?

This question is related to xml xsd

The answer is


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.

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!


XSD Diagram is 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.

enter image description here


We offer a tool called DocFlex/XML XSDDoc that allows you to enjoy both things at once:

  • To have diagram represetation of your XML schema
  • To have all those diagrams embedded (and hyperlinked) in a highly sophisticated XML schema documentation

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):

XML schema documentation with diagrams generated by XMLSpy

Here you can see the full this doc: 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!)


Currently, we've also implemented similar integrations with other XML editors:

With <oXygen/> XML Editor:

XSDDoc with diagrams generated by <oXygen/> XML Editor

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

With Liquid XML Studio:

XSDDoc with diagrams generated by Liquid XML

See: 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:

  1. To show what a result content model (represented by the given component) would look. That's the approach of XMLSpy.
  2. 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.

I personally believe that the diagrams generated by XMLSpy are more useful.

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...


That picture is generated from a XML Schema editing tool, such as Altova's 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.


There is a new free-to-use webtool, where you can view any xml schema:

Online XML Schema Viewer

www.xml-tools.net

It's written completely in JavaScript, so it's running in most modern browsers.


We use Liquid XML Studio, it provides a intuitive editable representation of an XSD schema. It also shows the annotations inline, which we find very useful and the split code/gfx view is invaluable when writting or editing an XSD.

Liquid XML Studio XSD Editor


On Linux (with mono, available via apt-get on Debian) and Windows:

If you are on Windows I recommend you have a look at:

Both tools are free and both are able to provide similar visualizations as shown in your example.


You can use XMLGrid's Online viewer which provides a great XSD support and many other features:

  • 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.

Screenshot:

Screenshot


Here is my approach- download the freemind and CAM XML Template Editor. Then open CAM XML, create new Template from XML, View -> View Template As Mind Map
Pros of this solution:

  • 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.

If someone works with IBM Rational Application Developer then XSD browser is built in it.


Visual Studio 2013 has a pretty cool visualizer built in.

File -> Open -> File pick your .xsd and then drag elements from XML Schema Explorer onto the designer surface.


The Oracle JDeveloper 11g built-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 Indigo but not for Juno). If I am not mistaken Oracle makes the JDeveloper available for free (only requires registration at the OTN).

enter image description here


The open source command line java application xsdvi creates 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.

Here is an example of a generated diagram

http://xsdvi.sourceforge.net/ipo.svg

The software can be downloaded from

http://sourceforge.net/projects/xsdvi/

It can be run as follows (assuming Java is installed and java.exe is in the path):-

  1. Go to the dist/lib folder.
  2. Run the following command java -jar xsdvi.jar <input1.xsd> [<input2.xsd> [<input3.xsd> ...]] [style]

Try my xsd-viewer available from https://github.com/santhosh-tekuri/jlibs.


Grid-ML Schema Viewer is great for searching and visualizing XML Schemas: https://gridml.com/xml-schema-viewer. I find it better than other tools when it comes to large schemas or when browsing through a diagram is not feasible. The tool also allows you to copy the XPath or JSON path of the selection item.

Grid-ML Schema Search Screen