154

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?

yucer
  • 4,431
  • 3
  • 34
  • 42
matt
  • 1,611
  • 2
  • 11
  • 4
  • 1
    it looks like the [tool I found](http://stackoverflow.com/questions/2486758/how-to-visualize-an-xml-schema/22236135#22236135) is the one the OP had a screen shot of. – toddmo Mar 25 '15 at 20:06
  • 3
    If you are using Confluence, check out the new XSD viewer plugin [in the Atlassian Marketplace](https://marketplace.atlassian.com/plugins/nl.avisi.confluence.plugins.xsdviewer) –  Feb 26 '13 at 11:52
  • Which programming language are you using? If you just looking for a software recommendation, there are better StackExchange sites for that. – Aminadav Glickshtein Aug 18 '19 at 11:23

15 Answers15

73

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]
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
Erik Sjölund
  • 10,690
  • 7
  • 46
  • 74
  • 3
    usage: `java -jar xsdvi.jar [ [ ...]] [style]` (from xsdvi.zip /res/readme.txt) – roblogic Jun 13 '16 at 22:59
  • The only problem with this tool is the SVG generated is a bit slow. Like, if I 'collapse all' after opening it takes about fifteen seconds for it collapse. But its free...so... – An Illusion Mar 07 '17 at 17:08
  • Great open source software! the only issue is that the SVG will be big file and click on the +/- button will become very slow(3-5 seconds) – Xin Meng May 21 '17 at 12:41
  • Great tool! I wonder if it's possible to make such transformation XSD->SVG with XSLT – Dima Fomin Jun 20 '17 at 17:10
  • You guys have to buy a faster computer :) It works ok for me, really nice tool – debuti Dec 21 '17 at 10:26
  • It seems it wasn't updated more than 10 years... XSD definition is not evolving too fast, but this still rises the question if the format support is up to date. – Daddy32 Aug 28 '19 at 08:23
  • Tried this and XSD Diagram with a complex XSD 700kb and 150kb approximately. This tool generate exception in thread "main" java.lang.OutOfMemoryError: Java heap space even after giving over a GB of memory. I'd recommend XSD Diagram for interactive viewing after trying these two – MattH Aug 18 '20 at 13:38
  • This tool created 1.2 GiB svg file which is doubly usable, as it loads forever :/ – PeterM Jun 12 '23 at 10:34
62

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

toddmo
  • 20,682
  • 14
  • 97
  • 107
  • 3
    nice one, runs even with latest Mono-MDK (4.0) on OSX. Exactly what I was looking for – Erich Eichinger Jul 22 '15 at 10:05
  • 1
    Brilliant little software. Super light weight and does not need JRE, fast. Love it. – Mohammed Lokhandwala May 03 '20 at 07:07
  • This is pretty good. – Uwe Ziegenhagen Jun 02 '20 at 19:22
  • And it's in the [default ubuntu repository](https://packages.ubuntu.com/focal/xsddiagram) - no idea why the official website doesn't mention this? – pateksan Mar 15 '21 at 23:02
  • Is there an updated version? This bases on .NET Framework 2.0/3.5, which both are deprecated. – Max Jan 11 '23 at 08:42
  • @Max, what happens when you download 2.0 and run it with that? – toddmo Jan 11 '23 at 18:37
  • @toddmo 2.0 is no longer supported, so I am not allowed to use this version any longer. This is very restricted in companies. – Max Jan 18 '23 at 09:40
  • @Max, I know this doesn't help you, but it might be time to just give up on `xml/xsl/xslt`. I said goodbye and started using `json` and never looked back. There's no tooling in VS Code for xml gridviews anymore, for example. The xslt libraries are flaky and pickings are slim b/c very few are working on it any more. If you feel you must download the source code and rebuild it with latest .Net, please put it up on Github as public so you (and the world) will always have it. – toddmo Jan 19 '23 at 00:58
  • @toddmo you are right in general, we never used xml as data format again since this project, json is the better standard, total agree. But - this is an old project, still running, and the replacement of xml by json would have a big impact, so no option. – Max Jan 19 '23 at 09:48
32

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

congusbongus
  • 13,359
  • 7
  • 71
  • 99
jelies
  • 9,110
  • 5
  • 50
  • 65
30

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

Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
  • 1
    JDeveloper (Java edition) did the job for me, tried other softwares mentioned here but no luck. – SyAu Jun 20 '13 at 04:48
  • 2
    Watch out when using it on the OSX: after unpacking the .zip file the JDeveloper.app won't start because of a file permission problem. You must set the executable bit on /Applications/jdeveloper/JDeveloper.app/Contents/MacOS/JDeveloper. Then, it still won't start until you save the path of your JDK in ~/.jdev_jdk like this: echo $JAVA_HOME > ~/.jdev_jdk – user17481 Jul 08 '13 at 14:34
  • This works like a charm! We used to use XMLSpy for adding pictures of the API which led to some awkward moments of finding someone who had a license, finding someone who had a trial, or finding someone who didn't already install the trial to make the pictures. It seemed silly to buy a $500 program only for a couple of pictures. – Captain Man Sep 14 '16 at 19:27
24

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.

0 _
  • 10,524
  • 11
  • 77
  • 109
datentyp
  • 1,371
  • 12
  • 9
  • 2
    XSD Diagram is really nice. Thanks. One thing to note: When you load up an XSD, the app doesn't show anything on the diagram tab, not even the root element. I thought it was broken, but it turns out you just have to explicitly tell it which elements to show. – dan-gph Jun 30 '15 at 04:52
  • best answer ! for linux, `sudo apt install xsddiagram` to install XSDDiagram – Kevin Chou Jan 28 '21 at 13:50
20

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!

Alexei Tenitski
  • 9,030
  • 6
  • 41
  • 50
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
15

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.

APC
  • 144,005
  • 19
  • 170
  • 281
6

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

Sprotty
  • 5,676
  • 3
  • 33
  • 52
Leonid Rudy
  • 255
  • 4
  • 5
5

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.

ambidexterous
  • 832
  • 12
  • 21
  • How to open designer surface? – Nitish Upreti Apr 11 '17 at 17:04
  • 1
    Design surface should open up when you do File -> Open -> pick .xsd file. At that point your xml schema isn't displayed yet, so the designer surface is sort of empty... It will open up as a blank tab with some instructions on what to do. The text reads "Visualize nodes in your XML schema set by dragging them from the XML Schema Explorer onto the design surface" You have to click on that word XML Schema Explorer it's a link that will open up a tab on the side (that tab will then contain your xml schema pieces which you can drag onto the designer surface) – ambidexterous Apr 12 '17 at 18:20
  • I'm not sure but it might be a feature that's available only on the Enterprise edition of the VS. I've not tried with other VS editions. – ambidexterous Apr 12 '17 at 18:21
  • 1
    Visual Studio 2017 also can show XSD structure. – Tony Jul 08 '17 at 22:05
5

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.

3

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.
0x6B6F77616C74
  • 2,559
  • 7
  • 38
  • 65
1

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

Captain Man
  • 6,997
  • 6
  • 48
  • 74
Santhosh Kumar Tekuri
  • 3,012
  • 22
  • 22
  • Trying this but http://deadlock.netbeans.org/maven2 gives a 404 error, and if I use the org-netbeans-swing-outline JAR file from NetBeans 6.9.1, I get an NPE at DefaultRenderDataProvider.java:49 – Andrew Swan Sep 29 '10 at 05:26
  • deadlock.netbeans.org/maven2 is down. now I used my personal repository. try with new sources... – Santhosh Kumar Tekuri Sep 29 '10 at 16:34
1

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

Sprotty
  • 5,676
  • 3
  • 33
  • 52
0

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

ctomek
  • 1,696
  • 16
  • 35
0

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